arr = [(3,2), (1,2), (0,4), (9,7)] k = lambda x : x[0] #key, optional rev = False # reverse, optional sorted(arr, key=key, reverse=reverse)