Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #2199 > unrolled thread

Re: Guido rethinking removal of cmp from sort method

Started byIan Kelly <ian.g.kelly@gmail.com>
First post2011-03-29 17:36 -0600
Last post2011-03-29 17:23 -0700
Articles 2 — 2 participants

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Guido rethinking removal of cmp from sort method Ian Kelly <ian.g.kelly@gmail.com> - 2011-03-29 17:36 -0600
    Re: Guido rethinking removal of cmp from sort method Paul Rubin <no.email@nospam.invalid> - 2011-03-29 17:23 -0700

#2199 — Re: Guido rethinking removal of cmp from sort method

FromIan Kelly <ian.g.kelly@gmail.com>
Date2011-03-29 17:36 -0600
SubjectRe: Guido rethinking removal of cmp from sort method
Message-ID<mailman.2.1301441811.2990.python-list@python.org>
On Tue, Mar 29, 2011 at 5:06 PM, MRAB <python@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.

[toc] | [next] | [standalone]


#2201

FromPaul Rubin <no.email@nospam.invalid>
Date2011-03-29 17:23 -0700
Message-ID<7xwrjh5ue0.fsf@ruckus.brouhaha.com>
In reply to#2199
Ian Kelly <ian.g.kelly@gmail.com> writes:
> cmp_to_key(lambda x, y: -cmp(x, y))

cmp_to_key(lambda x, y: cmp(y, x))

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web