sort a list

G

Guest

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?

Thanks.
 
D

Diez B. Roggisch

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,228
Latest member
MikeMichal

Latest Threads

Top