Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python collections Counter sort by key

# Just use sorted()
from collections import Counter
counter = Counter({'A': 10, 'C': 5, 'H': 7})
counter.most_common()
>>>[('A', 10), ('H', 7), ('C', 5)]
sorted(counter.items())
>>>[('A', 10), ('C', 5), ('H', 7)]
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #python #collections #Counter #sort #key
ADD COMMENT
Topic
Name
9+5 =