Sorting a dictionary

Alex alex at
Tue Mar 14 00:02:55 CET 2000

> l=map(lambda x:(x[1][2], x[1][1], x[1][0], x[0]), mydict.items())
> l.sort()

A faster version along those lines might be

l = map (None, mydict.values (), mydict.keys ())
l.sort ()
l.reverse ()

...but your version seems to be doing something different to what I
thought Rob was doing, so perhaps I've misunderstood.


More information about the Python-list mailing list