| Store | Cart

sorting a list

From: P@draigBrady.com <P...@draigBrady.com>
Wed, 10 Mar 2004 13:10:16 +0000
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?

If you want to sort textual data sensitive to
the current user's language do this:

a=['a','f','F','A','D']
import locale
locale.setlocale(locale.LC_ALL,"")
a.sort(locale.strcoll)

-- 
P?draig Brady - http://www.pixelbeat.org

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