Sort a list of lists (or list of tuples) by ascending order
arr = [[4, 3, 2], [3, 3, 3], [2, 3, 1], [1, 1, 1], [1, 2, 3], [2, 2, 2], [3, 4, 1]] print arr s = sorted(arr, key=lambda x : (x[0], x[1], x[2])) print s