Answers for "sort python nested list according to a value"

1

sort python nested list according to a value

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
Posted by: Guest on February-04-2022

Code answers related to "sort python nested list according to a value"

Python Answers by Framework

Browse Popular Code Answers by Language