Created
July 5, 2011 19:27
-
-
Save acrymble/1065661 to your computer and use it in GitHub Desktop.
Python Sort a dictionary of word-frequency Pairs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Sort a dictionary of word-frequency pairs in | |
# order of descending frequency. | |
def sortFreqDict(freqdict): | |
aux = [(freqdict[key], key) for key in freqdict] | |
aux.sort() | |
aux.reverse() | |
return aux |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment