Answers for "python sort based on 2 keys"

1

python sort two key

s = sorted(s, key = lambda x: (x[1], x[2]))
Posted by: Guest on May-07-2020
0

python sort based on multiple keys

>>> def multisort(xs, specs):
...     for key, reverse in reversed(specs):
...         xs.sort(key=attrgetter(key), reverse=reverse)
...     return xs
Posted by: Guest on August-24-2020

Code answers related to "python sort based on 2 keys"

Python Answers by Framework

Browse Popular Code Answers by Language