[Python-bugs-list] list.sort() with sort function (PR#131)
Sam Rushing
rushing@eGroups.net
Wed, 17 Nov 1999 23:18:43 -0800 (PST)
Tim Peters writes:
> Not a bug. Amazingly enough, see thread "Python 1.5.2 list sorting bug"
> from just a couple weeks ago (on comp.lang.python) for detailed discussion.
I guess what turned off my search-usenet instincts is that I *knew*
that it used to work that way... I even passed the example on to
others to defend against temporary insanity.
> If the intent of the above was to sort in reverse order,
>
> >>> l.sort(lambda a, b: cmp(b, a))
> >>> l
> [342, 23, 17]
> >>>
>
> or, quicker,
>
> >>> l.sort()
> >>> l.reverse()
> >>> l
> [342, 23, 17]
> >>>
This is what I usually do - I pull the sort key to the front of a
tuple and use sort(). In this case I had a small amount of data,
and I was sorting on a field buried two tuples deep. I trivialized
the example to expose the 'bug' in its simplest form.
Sorry for the false alarm! But I learn that all sorts of interesting
people are hiding behind the faceless python bug-reporting system. 8^)
-Sam