help printing dictionary, sorted by values.
jwilliam at xmission.com
Tue Aug 17 01:16:47 EDT 1999
I have searched and searched the docs and am really frustrated with
All I can seem to find is bits and pieces that hint about dictionaries.
I finally found a table under mappings that listed the methods. But
I couldn't find anything that would list each data type and what methods
are available. What I am trying to do is take a file with a bunch of
entries that appear more than once and list the count of each occurance
in order of the highest count. So if the file looked like:
Then is would print:
I thought a dictionary would work great, but can't seem to figure out
how to sort it by values and also get the key.
list = dict.values()
Then I get lost. And the counts aren't going to be unique.
Thanks for any help. Please point me to where the methods are listed
the dictionary. And some examples of dictionaries would be helpful.
More information about the Python-list