Looking for a different version of sort
Delaney, Timothy C (Timothy)
tdelaney at avaya.com
Wed Jun 16 04:32:43 CEST 2004
Brian McGonigle wrote:
> I'm a Perl programmer learning Python (up to chapter 7 in Learning
> Python, so go easy on me :-) and I find that I look to do things in
> Python the way I would do them in Perl. In Perl functions and methods
> usually only return and undefined value in the event of an error, make
> an endless number of compound statements possible. Is there a version
> of sort() I could import from somewhere that returns a reference to
> the object on which it was performed, rather than returning "None".
Python 2.4 includes `sorted` as a builtin which makes a copy of the
iterable passed, sorts it and returns it.
There is no function available which sorts in-place and returns a
reference to the list sorted, but it's very simple to write a function
to do it ...
def inplace_sort (l):
More information about the Python-list