Created
September 2, 2016 12:43
-
-
Save neoshrew/82de9f91a30d2f36d0686884fd9e7f3d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$python3 test.py | |
a | |
A | |
À La Garçonne | |
b | |
B | |
$python2 test.py | |
a | |
A | |
À La Garçonne | |
b | |
B | |
$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# encoding: utf8 | |
from __future__ import unicode_literals, print_function | |
from functools import cmp_to_key | |
import locale | |
locale.setlocale(locale.LC_ALL, '') | |
data = [ | |
"B", | |
"b", | |
"À La Garçonne", | |
"A", | |
"a", | |
] | |
for i in sorted(data, key=cmp_to_key(locale.strcoll)): | |
print(i) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
So this doesn't appear to work in 2.7.10 or less. It works in 2.7.12. No idea about 2.7.11.