python sort a list tuple code example
Example 1: pyhon sort a list of tuples
sorted([('abc', 121),('abc', 231),('abc', 148), ('abc',221)], key=lambda x: x[1])
Example 2: sort by tuple
sorted_by_second = sorted(data, key=lambda tup: tup[1])
sorted([('abc', 121),('abc', 231),('abc', 148), ('abc',221)], key=lambda x: x[1])
sorted_by_second = sorted(data, key=lambda tup: tup[1])