Hacker News new | ask | show | jobs
by orf 2288 days ago
> sorted(my_dict.keys())

Or just:

> sorted(my_dict)

Sorting keys like that is also weird. Keys are insertion ordered, utilize that property where you can and avoid needlessly re-sorting.

1 comments

Glorious, Thank you kind soul for listening to my slightly raving rant.

Now I feel several sorts of ashamed at missing what is kind of a core function.

salutes

Fwiw, make sure you're using a newish python version. They weren't always sorted by default.
3.6+