name_age = [["A", 7], ["B", 5], ["C", 35]] name_age.sort(key=lambda age: age[1]) #name_age.sort(key=lambda age: age[1], reverse = True) print(name_age) #sorts according to the 1th value of the inner loop