LernerPython blog, from Reuven Lerner: Sorting a Counter by key: Ordering a text histogram with sorted

Wait 5 sec.

Let’s sort yesterday’s Python histogram by date! Counter is a dict, and the keys are ints, so sorted will do what we want:for date, count in sorted(Counter([one_tg.day for one_tg in us_holidays.get_named('Thanksgiving')]).items()): print(f'{date}: {count * 'x'}')The post Sorting a Counter by key: Ordering a text histogram with sorted appeared first on LernerPython.