On 2006-10-16, Ron Adam <[EMAIL PROTECTED]> wrote:
>
> I have several applications where I want to sort lists in
> alphabetical order. Most examples of sorting usually sort on
> the ord() order of the character set as an approximation.  But
> that is not always what you want.

Check out strxfrm in the locale module.

>>> a = ["Neil", "Cerutti", "neil", "cerutti"]
>>> a.sort()
>>> a
['Cerutti', 'Neil', 'cerutti', 'neil']
>>> import locale
>>> locale.setlocale(locale.LC_ALL, '')
'English_United States.1252'
>>> a.sort(key=locale.strxfrm)
>>> a
['cerutti', 'Cerutti', 'neil', 'Neil']

-- 
Neil Cerutti
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to