Sorting of list containing tuples

bearophileHUGS at lycos.com bearophileHUGS at lycos.com
Thu May 18 15:52:12 EDT 2006


>>> l = [(2,3),(3,2),(6,5)]
>>> from operator import itemgetter
>>> sorted(l, key=itemgetter(1), reverse=True)
[(6, 5), (2, 3), (3, 2)]

Bye,
bearophile




More information about the Python-list mailing list