python sort list of lists by specific index
# Basic syntax:
nested_list.sort(key = lambda nested_list: nested_list[1])
# Example usage:
nested_list = [['I', 4, 28],
['O', 2, 20],
['U', 1, 20],
['A', 3, 21],
['FISH', 42, 23]]
nested_list.sort(key = lambda nested_list: nested_list[1])
print(nested_list)
--> [['U', 1, 20], ['O', 2, 20], ['A', 3, 21], ['I', 4, 28], ['FISH', 42, 23]]
# Note that the list of lists was sorted in place and that the nested
# lists were all sorted by their first index (*Python is 0-indexed)