Не знал, что существует объект Counter
для такой задачи. Вот как я это сделал тогда, похоже на твой подход. Вы можете выполнить сортировку по представлению того же словаря.
#Takes a list and returns a descending sorted dict of words and their counts
def countWords(a_list):
words = {}
for i in range(len(a_list)):
item = a_list[i]
count = a_list.count(item)
words[item] = count
return sorted(words.items(), key = lambda item: item[1], reverse=True)
Пример:
>>>countWords("the quick red fox jumped over the lazy brown dog".split())
[('the', 2), ('brown', 1), ('lazy', 1), ('jumped', 1), ('over', 1), ('fox', 1), ('dog', 1), ('quick', 1), ('red', 1)]
Вы можете переключиться на исследование репозитория SVN, а затем изменить свойства репозиториев или отказаться от них