I have a dictionary with a key as words and values ββas ints.
Is it possible to sort a dictionary by values?
I want to be able to take the 10 most popular words in my dictionary. Values ββrepresent the number of words, and 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 still have, but it is only the print of the first 10 points in the dictionary. How do I print the 10 most popular items? (i.e. the values ββwith the highest int value as the value?)
source share