Guido rethinking removal of cmp from sort method

Paul Rubin no.email at nospam.invalid
Tue Mar 15 00:59:54 EDT 2011


Nobody <nobody at nowhere.com> writes:
>> 2,7,1,8,...  You can sort these with cmp but not with key.
>
> Is there some restriction on the return type of the key= function? If not,
> you can define a class with appropriate comparison methods and have key=
> return instances of that class.

Sorry, yeah, of course you can do it that way, but it's bloody ugly and
you're no longer gaining the supposed benefit of the DSU pattern.



More information about the Python-list mailing list