Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
one liner solution in Creative category for Frequency Sorting by Sim0000
checkio=lambda n:sorted(n,key=lambda x:(-n.count(x),x))
if __name__ == '__main__':
#These "asserts" using only for self-checking and not necessary for auto-testing
assert checkio([1, 2, 3, 4, 5]) == [1, 2, 3, 4, 5], "Already sorted"
assert checkio([3, 4, 11, 13, 11, 4, 4, 7, 3]) == [4, 4, 4, 3, 3, 11, 11, 7, 13], "Not sorted"
assert checkio([99, 99, 55, 55, 21, 21, 10, 10]) == [10, 10, 21, 21, 55, 55, 99, 99], "Reversed"
March 1, 2018
Comments: