Guido rethinking removal of cmp from sort method
Ian Kelly
ian.g.kelly at gmail.com
Tue Mar 29 19:36:18 EDT 2011
On Tue, Mar 29, 2011 at 5:06 PM, MRAB <python at mrabarnett.plus.com> wrote:
> I think I've found a solution:
>
> class NegStr:
> def __init__(self, value):
> self._value = value
> def __lt__(self, other):
> return self._value > other._value
IOW:
cmp_to_key(lambda x, y: -cmp(x, y))
This is still just taking a cmp function and dressing it up as a key.
More information about the Python-list
mailing list