18
Possible Duplicate:
Python: Sort a dictionary by value
d = {"a":4, "b":12, "c":2}
If I use sorted() with lambda:
s = sorted(d.items(), key=lambda(k,v):(v,k))
I get a list tuples (key,value) but I want a dict again:
{"c":2, "a":4, "b":12}
And doing dict(the_list_of_tuples) you're back to square one.