Skip to content

Instantly share code, notes, and snippets.

@redspider
Created December 25, 2010 10:08
Show Gist options
  • Save redspider/754807 to your computer and use it in GitHub Desktop.
Save redspider/754807 to your computer and use it in GitHub Desktop.
word_count = dict()
word_file = open('text.txt',r)
for line in word_file:
for word in line.split(' '):
word_count[word] = word_count.get(word,0)+1
words = word_count.keys()
words.sort(lambda a,b: cmp(word_count[a],word_count[b]))
print words.join('\n')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment