How to sort a list of lists by an index of each inner list in Python Use sorted() with operator.itemgetter() use sorted() with a lambda expression