{{{#!python d,l,s={},[],[] l=file('test.txt').read().split() for word in l: d[word]=l.count(word) for word, count in d.items(): s.append([count, word]) s.sort() for count, word in s: print word, count }}}