Answers for "use lambda to sort python"

4

sorted python lambda

lst = [('candy','30','100'), ('apple','10','200'), ('baby','20','300')]
lst.sort(key=lambda x:x[1])
print(lst)
Posted by: Guest on June-23-2020
0

python sort multiple keys

records.sort(
  key = lambda l: (l[0], l[2])
)
Posted by: Guest on April-04-2020

Python Answers by Framework

Browse Popular Code Answers by Language