l=[[1,4], [2,7], [10,1], [1,2], [10,6], [2,1]] print sorted(l,key=lambda x: (x[0],x[1]))
Or just sorted(l) of l.sort() , since your items are sorted naturally.
A better example would be sorting by the second value only:
print sorted(l,key=lambda x: (x[1])) [[10, 1], [2, 1], [1, 2], [1, 4], [10, 6], [2, 7]]
Padraic cunningham
source share