+ 1

i still dont know how 'sort' work with 'key=takeSecond'. Plz mind blowing me !!!

# take second element for sort def takeSecond(elem): return elem[1] # random list random = [(2, 2), (3, 4), (4, 1), (1, 3)] # sort list with key random.sort(key=takeSecond) # print list print('Sorted list:', random)

21st Dec 2019, 5:17 AM
Lewsijght G
Lewsijght G - avatar
1 Respuesta