Re: is this sort method the same as the one in python 2.4

2005-01-30 Thread Raymond Hettinger
"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=

Re: is this sort method the same as the one in python 2.4

2005-01-30 Thread Raymond Hettinger
"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()

Re: is this sort method the same as the one in python 2.4

2005-01-30 Thread 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 On Sun, 30 Jan 2005 08:30:17 +0100 "Fredrik Lundh" <[EM

Re: is this sort method the same as the one in python 2.4

2005-01-30 Thread Lowell Kirsh
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

Re: is this sort method the same as the one in python 2.4

2005-01-29 Thread Fredrik Lundh
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

Re: is this sort method the same as the one in python 2.4

2005-01-29 Thread Raymond Hettinger
"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

is this sort method the same as the one in python 2.4

2005-01-29 Thread 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()? The obvious difference is that my method is called as sort(se