Q: sort's key and cmp parameters
Fri Oct 2 01:16:52 CEST 2009
Duncan Booth <duncan.booth at invalid.invalid> writes:
> > Is there a real-life sorting task that requires (or is far more
> > efficient with) cmp and can't be easily achieved with key and reverse?
> There is no sorting task that *requires* cmp. If all else fails you can
> define a key class to wrap the original wrapper such that comparing the
> keys simply calls the comparison function that you *would* have used.
I would count that as key being far less efficient, though still
giving the same result.
More information about the Python-list