[issue23195] Sorting with locale (strxfrm) does not work properly with Python3 on BSD or OS X

2015-01-08 Thread Ned Deily

Changes by Ned Deily n...@acm.org:


--
title: Sorting with locale (strxfrm) does not work properly with Python3 on 
Macos - Sorting with locale (strxfrm) does not work properly with Python3 on 
BSD or OS X

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23195
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23195] Sorting with locale (strxfrm) does not work properly with Python3 on BSD or OS X

2015-01-08 Thread STINNER Victor

STINNER Victor added the comment:

 The postresq discussion and some earlier Python issues suggest using ICU to 
 properly implement Unicode functions like collation across all platforms.

In my experience, the locale module is error-prone and not reliable, especially 
if you want portability. It just uses functions provided by the OS. And the 
locales (LC_CTYPE, LC_MESSAGE, etc.) are process-wide which become a major 
issue if you want to serve different clients using different locales... Windows 
supports a different locale per thread if I remember correctly.

It would be more reliable to use a good library like ICU. You may try:
https://pypi.python.org/pypi/PyICU

Link showing how to use PyICU to sort a Python sequence:
https://stackoverflow.com/questions/11121636/sorting-list-of-string-with-specific-locale-in-python
= strings.sort(key=lambda x: collator[loc].getCollationKey(x).getByteArray())

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23195
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com