Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Work faster then (-items.count(x), items.index(x)) solution in Speedy category for Sort Array by Element Frequency by Gi-gik
from collections import Counter
def frequency_sort(items):
groups = Counter(items)
sort = sorted(groups.items(), key=lambda e: e[1], reverse=True)
for key, value in sort:
yield from [key]*value
March 14, 2020
Comments: