Craven - Sort Array by Element Frequency - Readable solution in Clear category for Sort Array by Element Frequency by corwin.ravenwood
from collections import Counter
# Returns list in order of frequency while maintaining previous relative order within equal frequency items.
return [n for n,count in Counter(items).most_common() for i in range(count)]
April 16, 2021