Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Sort Array by Element Frequency by twilyght
from collections import Counter
def frequency_sort(items):
counter = Counter(items)
sorted_by_first_occurrence = sorted(items, key=lambda x: items.index(x))
return sorted(sorted_by_first_occurrence, key=lambda x: counter[x], reverse=True)
May 3, 2020