| Store | Cart

sorting a list

From: Daniel Yoo <d...@hkn.eecs.berkeley.edu>
Wed, 10 Mar 2004 02:06:46 +0000 (UTC)
ketulp_baroda at yahoo.com wrote:
: Hi
: I want to sort a list.
: My problem is:

:>>> a=['a','f','F','A','D']
:>>> a.sort()
:>>> a
: ['A','D', 'F', 'a', 'f']


: But I am actually looking for an output:
: ['A','a','D','F','f']

: Is there any module to sort a list this way?


Hi Ketulp,


Yes, Python's lists do have a sort() method that we can use to do
sorting.  If you're like to learn more, there's a great Sorting HOWTO
by Andrew Dalke that should be helpful:

    http://www.amk.ca/python/howto/sorting/sorting.html


Hope this helps!

Recent Messages in this Thread
ketu...@yahoo.com Mar 09, 2004 11:13 pm
Paul McGuire Mar 09, 2004 11:23 pm
Peter Otten Mar 09, 2004 11:35 pm
Karl Pflästerer Mar 10, 2004 12:06 am
ketu...@yahoo.com Mar 10, 2004 11:08 am
Daniel Yoo Mar 10, 2004 02:06 am
P...@draigBrady.com Mar 10, 2004 01:10 pm
Messages in this thread