Custom Search

Wednesday, February 27, 2013

How To Python Sorting Tuple of Tuples

import operator

tup=(("a",2),("b",2),("a",1))

sorted(tup, key=operator.itemgetter(1, 0))

sorted(tup, key=operator.itemgetter(1, 0), reverse=True)

No comments:

Post a Comment