sort a list

Diez B. Roggisch deets at nospam.web.de
Sat Oct 27 18:16:59 CEST 2007


_nospamnet_ at arcor.de schrieb:
> hello,
> 
> I'm new to python and this list.I hope this question don't repeat an old story on the list.
> 
> I have a number list,say it's [3,2,1,4,5],I want to sort it as [1,2,3,4,5],how to do?

your_list.sort()

Please read the documentation, all of this is properly documented.

And even google would have brought that up really fast:

google:python list sort

1) http://xahlee.org/perl-python/sort_list.html (Oh my, it's Xah....)

2) http://docs.python.org/lib/typesseq-mutable.html (official python docs)


So the first two links give you all the information you needed.

Diez



More information about the Python-list mailing list