I need to write a counter to a file in order of most occurring to least occurring but I am having a little trouble. When I print the counter it prints in order but when I call counter.items()
and then write it to a file it writes them out of order.
I am trying to make it like this:
word 5
word2 4
word3 4
word4 3