Sorting a dictionary

Alex alex at somewhere.round.here
Mon Mar 13 18:02:55 EST 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.

Alex.



More information about the Python-list mailing list