Sorting a dictionary by value

Roy Culley rgc at swissonline.ch
Thu Jul 4 22:09:31 EDT 2002


I'm sorry if this is a novice question but I have searched google
and the python FAQ and haven't found an answer.

I have a large dictionary where I want to sort and print based
on the largest values in a dictionary and not the keys.

Now in perl you can do:

    @Keys = sort { $Hash{$b} <=> $Hash{$a} } keys %Hash;

Is there any such magic for python?



More information about the Python-list mailing list