sorting a list

Daniel Yoo dyoo at hkn.eecs.berkeley.edu
Tue Mar 9 21:06:46 EST 2004


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!



More information about the Python-list mailing list