Answers for "sort python key lambda"

2

python sort based off lambda

a = sorted(a, key=lambda x: x.modified, reverse=True)
Posted by: Guest on March-22-2021
4

python lambda key sort

>>> student_tuples = [
...     ('john', 'A', 15),
...     ('jane', 'B', 12),
...     ('dave', 'B', 10),
... ]
>>> sorted(student_tuples, key=lambda student: student[2])   # sort by age
[('dave', 'B', 10), ('jane', 'B', 12), ('john', 'A', 15)]
Posted by: Guest on May-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