Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
simple solution in Clear category for Sort Array by Element Frequency by wooilkim
from collections import Counter
def frequency_sort(items):
counter = Counter(items)
return sorted(items, key=lambda x: (-counter[x], items.index(x)))
May 27, 2021