Sorting of list containing tuples

Ronny Mandal ronnyma at math.uio.no
Thu May 18 21:29:59 CEST 2006


Hi!

Assume we have a list l, containing tuples t1,t2...

i.e. l = [(2,3),(3,2),(6,5)]

And now I want to sort l reverse by the second element in the tuple,
i.e the result should ideally be:

 l = [(6,5),(2,3),(3,2)]


Any ideas of how to accomplish this?


Thanks,

Ronny Mandal



More information about the Python-list mailing list