I have a counter that I would like to sort in the following way:
Counter({'M': 9, 'L': 5, 'P': 5, 'S': 2, 'd': 1, 'T': 1})
when I use my code, here is what it gives me:
Counter({'M': 9, 'P': 5, 'L': 5, 'S': 2, 'T': 1, 'd': 1})
I tried the function sorted(), but when I use it, its return value is not a counter anymore.
Here is my code, how would you do that?
def most_encountered_letters(dictionnary):
counter = collections.Counter()
for line in dictionnary:
words = line.split(',')[0].split(' ')
for word in words:
counter[word[0]] += 1
print(counter)
return counter.most_common(5)