How to Sort a List of Tuples? – Most Pythonic Way!

Did you already try to sort a list of tuples? And when you saw the result, it wasn’t quiet what you expected? Well, this happend to me when I went deeper into Python and I suppose, it also happened to you, since you are looking for a solution. This definitely shows that you are an advanced Python programmer already!

Quick Answer

Use Python’s built-in sorted() function or call the method sort() on the list you want to sort. Both of them have an optional parameter key that accepts a function. Pass a function here which computes a key-value from each tuple in

Continue reading the original article