Very basic, sorting a list ???

cokofreedom at cokofreedom at
Thu Nov 29 10:55:40 CET 2007

On Nov 29, 10:40 am, Stef Mientki <S.Mientki-nos... at>
> Peter Decker wrote:
> > On Nov 28, 2007 7:22 PM, stef mientki <stef.mien... at> wrote:
> >>     print 'xx3',ordered_list.sort()
> > The sort() method returns None. It sorts the list in place; it doesn't
> > return a copy of the sorted list.
> Thank you all for the answers,
> I do understand now,
> although I find it rather non-intuitive.
> I didn't expect a copy, but a reference to itself wouldn't be asked too much ?
> Why does it return None, instead of the sorted object itself ?
> I guess it would cost almost exactly the same processing power.
> cheers,
> Stef Mientki

>From the Docs;

The sort() and reverse() methods modify the list in place for economy
of space when sorting or reversing a large list. To remind you that
they operate by side effect, they don't return the sorted or reversed

More information about the Python-list mailing list