Skip to content

Instantly share code, notes, and snippets.

@neoshrew
Created September 2, 2016 12:43
Show Gist options
  • Save neoshrew/82de9f91a30d2f36d0686884fd9e7f3d to your computer and use it in GitHub Desktop.
Save neoshrew/82de9f91a30d2f36d0686884fd9e7f3d to your computer and use it in GitHub Desktop.
$python3 test.py
a
A
À La Garçonne
b
B
$python2 test.py
a
A
À La Garçonne
b
B
$
# 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)
@neoshrew
Copy link
Author

neoshrew commented Sep 2, 2016

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment