python sort list of tuples by both elements code example Example: python sort list according to two elements in tuple sorted(unsorted, key=lambda element: (element[1], element[2]))