Using tricky key functions for sort/min/max in Python

25 September 2013, 19:53

After reading another exhortation for developers to blog (they used to be way more common…) I was shamed enough into writing up something I have enjoyed working on lately – key functions for sort/min/max in Python. Doesn’t sound that exciting but it can be a powerful technique and using key functions encourages you to write better code than trawling through iterables yourself. Everything I have read about key functions is super basic. So maybe this is sorting 201. Have I missed some great resources that cover this kind of thing? Let me know.

I started writing a blog post and then it turned out to be way easier to write the whole thing as an IPython Notebook. So it’s committed in a Github gist, and you can easily view it online via the notebook viewer. I wish I could embed it here but there doesn’t seem to be a way to do that. So – go read this thing I wrote. Corrections etc welcome.

tags:

---

Comment

Subscribe to comments on this post: rss / atom

Commenting is closed for this article.