Very basic, sorting a list ???

i3dmaster i3dmaster at gmail.com
Thu Nov 29 03:57:11 CET 2007


On Nov 28, 4:22 pm, stef mientki <stef.mien... at gmail.com> wrote:
> hello,
>
> I'm trying to sort a list, using the same list at the commandline works,
> but in a program it doesn't.
>
> Here is the code
>     print 'xx1',type(ordered_list)
>     print 'xx2',ordered_list
>     print 'xx3',ordered_list.sort()
>
> And this is the result
> xx1 <type 'list'>
> xx2 [14, 12, 10]
> xx3 None
>
> What am I doing wrong ?
>
> thanks,
> Stef Mientki

sorted(alist) returns a copy of the original list with sorted order,
that's probably what you really need. Yes, you should read
documentations more.



More information about the Python-list mailing list