Q: sort's key and cmp parameters
Duncan Booth
duncan.booth at invalid.invalid
Thu Oct 1 15:55:03 EDT 2009
kj <no.email at please.post> wrote:
> 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.
This has been discussed before and if you google sufficiently you should
find the code that has been posted to do exactly that.
More information about the Python-list
mailing list