Noteworthy

Sunday, March 30, 2008

Don't search for "python dict sort by value" since you'll get outdated answers. As of python 2.4, the "right" way to do this is:

from operator import itemgetter
sorted(d.iteritems(), key=itemgetter(1))


from http://blog.modp.com/2008/09/sorting-python-dictionary-by-value-take.html

Labels: