I have a dictionary with key as words and values as ints.
Is it possible to sort the dictionary by values?
I want to be able to take the top 10 most occurring words in my dictionary. The values represent the word counts and the keys represent the word.
counter = 9
for a,b in sorted(dict_.iteritems()):
if counter > 0:
print str(a),str(b)+"\n"
counter-=1
This is what i have so far but it is only printing off the first 10 items in the dictionary. How would I print off the top 10 most frequent items? (ie The values with the highest int as the value?)