How to sort this without 'cmp=' in python 3?

Chris Angelico rosuav at gmail.com
Tue Oct 24 22:12:01 EDT 2023


On Wed, 25 Oct 2023 at 13:02, Mike H via Python-list
<python-list at python.org> wrote:
> Is it possible to use lambda expression instead of defining a `Key` class? Something like `sorted(my_list, key = lambda x, y: x+y > y+x)`?

Look up functools.cmp_to_key.

ChrisA


More information about the Python-list mailing list