I know there\'s tonnes of questions on python sorting lists/dictionaries already, but I can\'t seem to find one which helps in my case, and i\'m looking for the most efficient s
Something like this?
>>> a = {'a': (1, 2, 3), 'b': (3, 2, 1)} >>> b = a.items() >>> b [('a', (1, 2, 3)), ('b', (3, 2, 1))] >>> b.sort(key=lambda x:x[1][2]) # sorting by the third item in the tuple >>> b [('b', (3, 2, 1)), ('a', (1, 2, 3))]