← Back to team overview

launchpad-dev team mailing list archive

Re: Collation orders in Launchpad

 

On 3 June 2011 07:17, Martin Pool <mbp@xxxxxxxxxxxxx> wrote:
[...]
> Maybe as a simple place to start there should just be a "compare human
> strings" function that can be passed to sort(cmp=) and at least the
> .lower() will not be repeated.
[...]
> Maybe we should actually use locale.strcoll, rather than comparing the
> lowered forms?  <http://docs.python.org/library/locale.html>  istr
> this is rather better on non-English names.  For en_AU.UTF-8  it is
> case insensitive, though it is case sensitive in C.

Fwiw, the cmp argument to list.sort() and sorted() is deprecated, and
is gone in Python 3. However, I think strxfrm() can be used instead of
strcoll(), i.e. sorted(names, key=locale.strxfrm)


References