I have to count the word frequency in a text using python. I thought of keeping words in a dictionary and having a count for each of these words.
Now if I have to sort the words according to # of occurrences. Can i do it with same dictionary instead of using a new dictionary which has the key as the count and array of words as the values ?
You can use the same dictionary:
The second line prints:
If you only want a sorted word list, do:
That line prints: