Created
December 25, 2010 10:08
-
-
Save redspider/754807 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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