"Pedro Werneck"
>
> What about this ?
>
>
> #
> if sys.version_info >= (2,4):
> def sorted(iterable, *args, **kwds):
> seq = list(iterable)
> seq.sort(*args, **kwds)
> return seq
> #
>
> It worked against the TestSorted in lib/test/test_builtins.py
The key= and reverse=
"Lowell Kirsh"
> How come you reverse the list twice? And why does this preserve stability?
It's easy to see if you trace through the steps:
Given sample the following dataset and a desire to sort on the first field:
>>> data = [('a', 1), ('a', 2), ('b', 3)]
Here are the step:
>>> data.reverse()
What about this ?
#
if sys.version_info >= (2,4):
def sorted(iterable, *args, **kwds):
seq = list(iterable)
seq.sort(*args, **kwds)
return seq
#
It worked against the TestSorted in lib/test/test_builtins.py
On Sun, 30 Jan 2005 08:30:17 +0100
"Fredrik Lundh" <[EM
How come you reverse the list twice? And why does this preserve stability?
Raymond Hettinger wrote:
"Lowell Kirsh"
I'm trying to emulate the sorted() method introduced in python 2.4. The
only difference is that it takes a sequence as one of its arguments
rather than being a method of the sequence c
Raymond Hettinger wrote:
>> I'm trying to emulate the sorted() method introduced in python 2.4. The
>> only difference is that it takes a sequence as one of its arguments
>> rather than being a method of the sequence class. Does my method do the
>> same as the sorted()?
>
> Almost. This is closer
"Lowell Kirsh"
> I'm trying to emulate the sorted() method introduced in python 2.4. The
> only difference is that it takes a sequence as one of its arguments
> rather than being a method of the sequence class. Does my method do the
> same as the sorted()?
Almost. This is closer to the mark:
def
I'm trying to emulate the sorted() method introduced in python 2.4. The
only difference is that it takes a sequence as one of its arguments
rather than being a method of the sequence class. Does my method do the
same as the sorted()? The obvious difference is that my method is called
as sort(se