Light Mode
Dark Mode
Statistics Module
import statistics as stat


def frequency_sort(items):
    if len(items) <= 1:
        return items

    item_freq = []
    while len(items) >= 1:
        num = stat.mode(items)
        freq = items.count(num)
        for _ in range(0, freq):
            item_freq.append(num)
            items.remove(num)
    return item_freq

I have to go and see how/why that one liner LAMBDA code works because looking at it, I don't understand ... then again, I'm early on and haven't used lambda or the sorted() built-in at all, really.

Created: Jan. 29, 2022, 6:12 a.m.
Updated: Jan. 29, 2022, 9:41 a.m.
0
15
User avatar
TrexxaByte