how to put tuples in order in python code example Example: sort by tuple sorted_by_second = sorted(data, key=lambda tup: tup[1])