[Newbie] How to output dictionary sorted on content (not keys)

Ben Fairbank baf at texas.net
Thu Jul 4 08:20:28 EDT 2002


I have several long (thousands of entries) dictionaries of words used
in plays; associated with each word is the number of times it is used
in the play.  I have had no problem printing the words alphabetically
(send keys to a list, sort the list, access dictionary by the sorted
key list), but I have not found an elegant way to sort by  frequency
of use.  The best I have been able to do is a workable but inelegant
kluge that looks more like Basic than Python.  Is there a "Python Way"
of doing that?

Thanks for any ideas.

BAF



More information about the Python-list mailing list