Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Simple double key sort solution in Clear category for Frequency Sorting by new_hoschi
def frequency_sorting(numbers):
''' sorting the list first by their number of appearances, naturally the
order is from few to many so we have to reverse this ordering, e.g. by
writing a - in front. secondary key for the order is the value, which
should be from small to large, which python does naturally'''
return sorted(numbers,key=lambda x:(-numbers.count(x),x))
March 30, 2020