So I have the code below to count the number of words in a text file. I'd like to sort the output of this by words that appeared the greatest number of times to words that appeared the least number of times. How can this be accomplished?
ally = open("alice.txt", "r")
wordcount={}
for word in ally.read().split():
if word not in wordcount:
wordcount[word] = 1
else:
wordcount[word] += 1
for k,v, in wordcount.items():
print(k,v)