As in this example. You want to sort this list.
[('c', 2), ('b', 2), ('a', 3)]
exit:
[('a', 3), ('b', 2), ('c', 2)]
you must sort the two elements and the first
def letter_cmp(a, b): if a[1] > b[1]: return -1 elif a[1] == b[1]: if a[0] > b[0]: return 1 else: return -1 else: return 1
Finally:
just sort(letter_cmp)
RryLee Mar 18 '16 at 3:26 2016-03-18 03:26
source share