Python 1.5.2 list sorting bug

Olaf Delgado delgado at Mathematik.Uni-Bielefeld.DE
Thu Oct 28 18:02:19 EDT 1999


On Thu, 28 Oct 1999, Brian Kelley wrote:

> actually a much quicker test is:
> 
> Python 1.5.2 (#1, Oct 27 1999, 17:21:07) [C] on irix646
> Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
> >>> a = [3,4,5,1,2]
> >>> a.sort(lambda x,y: x>y)
> >>> a
> [3, 4, 5, 1, 2]
> >>>

Mmmh, this looks like a typical case of RTFM.
Or, in this case, RTFDS ... :)

Python 1.5.1 (#1, May  1 1999, 08:24:20)  [GCC egcs-2.91.66 19990314 
(e on linux2
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> a = [3, 4, 5, 1, 2]
>>> a.sort(lambda x, y: x > y)
>>> a
[1, 2, 3, 4, 5]
>>> a.sort.__doc__
>>> 

Python 1.5.2
(#3, Apr 29 1999, 20:12:29) [GCC 2.8.1] on linux2
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> a = [3, 4, 5, 1, 2]
>>> a.sort(lambda x, y: x - y)
>>> a
[1, 2, 3, 4, 5]
>>> a.sort.__doc__
'L.sort([cmpfunc]) -- sort *IN PLACE*; if given, cmpfunc(x, y) -> -1, 0,
1'
>>>

Seems like the specification was changed from 1.5.1 to 1.5.2. Not a bug
therefore, but a feature. :)

Cheers,
Olaf






More information about the Python-list mailing list