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
# Python code to sort the lists using the second element of sublists
# Inplace way to sort, use of third variable
def Sort(sub_li):
l = len(sub_li)
for i in range(0, l):
for j in range(0, l-i-1):
if (sub_li[j][1] > sub_li[j + 1][1]):
tempo = sub_li[j]
sub_li[j]= sub_li[j + 1]
sub_li[j + 1]= tempo
return sub_li
# Driver Code
sub_li =[['rishav', 10], ['akash', 5], ['ram', 20], ['gaurav', 15]]
print(Sort(sub_li))