Skip to content

Instantly share code, notes, and snippets.

@acrymble
Created July 5, 2011 19:27
Show Gist options
  • Save acrymble/1065661 to your computer and use it in GitHub Desktop.
Save acrymble/1065661 to your computer and use it in GitHub Desktop.
Python Sort a dictionary of word-frequency Pairs
# 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