Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
OrderedDict solution in Clear category for Sort Array by Element Frequency by martin.pilka
def frequency_sort(items):
from collections import Counter, OrderedDict
counts = Counter(items)
r = []
for i in sorted(OrderedDict.fromkeys(items).keys(), key=counts.get, reverse=True):
r.extend([i]*counts[i])
return r
Feb. 1, 2019
Comments: