Answers for "sort by the frequency of occurrences in Python"

0

sort by the frequency of occurrences in Python

from collections import Counter
print [item for items, c in Counter(a).most_common() for item in [items] * c]
# [5, 5, 5, 5, 3, 3, 3, 4, 4, 4, 1, 1, 2]
Posted by: Guest on May-03-2021

Code answers related to "sort by the frequency of occurrences in Python"

Browse Popular Code Answers by Language