sort accented string

Laurent laurentpointrahuel at clubtiretinternet.fr
Wed Jun 30 09:36:08 EDT 2004


Thank you very much Peter, that's a really great tip. You should try to
publish this one on the Internet 'cause I didn't find any web site
explaining this.

Bye.

Laurent

Peter Otten wrote:

> Laurent wrote:
> 
>> I'm french and I have a small sorting problem with python (and zope's
> 
> Try locale.strcoll():
> 
>>>> import locale
>>>> locale.setlocale(locale.LC_ALL, "fr_FR")
> 'fr_FR'
>>>> test = list("abéfgz")
>>>> test.sort()
>>>> test
> ['a', 'b', 'f', 'g', 'z', '\xe9']
>>>> test.sort(locale.strcoll)
>>>> test
> ['a', 'b', '\xe9', 'f', 'g', 'z']
>>>>
> 
> Peter




More information about the Python-list mailing list