Skip to content

Instantly share code, notes, and snippets.

@acrymble
Created July 5, 2011 19:27
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