+ 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)
0 Answers