sort accented string

Peter Otten __peter__ at web.de
Wed Jun 30 10:14:48 EDT 2004


Laurent wrote:

> Peter what about using this kind of tip with cmp() built-in ??
> 
> def myCompare(self,a,b):
>         cmp(a,b)
> 
> with a and b being french accented chars ???
> 
> Any idea ??

>From the documentation of the locale module:

"""
strxfrm(string)

Transforms a string to one that can be used for the built-in function cmp(),
and still returns locale-aware results. This function can be used when the
same string is compared repeatedly, e.g. when collating a sequence of
strings. 
"""

Peter




More information about the Python-list mailing list