Wrong Hungarian (hu_HU) sort order

40 Views Asked by At
import locale
locale.setlocale(locale.LC_COLLATE,'hu_HU.ISO8859-2')
print(sorted(['c', 'á', 'b', 'z', 'é', 'a', 'd', 'e', 'f', 'Ő', 'Ű', 'ő', 'ű'], key=locale.strxfrm))

Expected: ['a', 'á', 'b', 'c', 'd', 'e', 'é', 'f', 'Ő', 'ő', 'Ű', 'ű', 'z']

Actual: ['a', 'á', 'b', 'c', 'd', 'e', 'é', 'f', 'z', 'Ő', 'ő', 'Ű', 'ű']

Note that 'z' is supposed to be the last letter.

I know my code "works" because it does put the 'á' and 'é' in the right place (and the "regular" sorted puts them after 'z'), so the bug I is in the locale definition.

I have MacOS Venture 13.6.4, python 3.11.7

How could I "update" the locale definitions? Is it something in the python or does it use the system locales?

Note: I tried to install PyICU and zope.ucol, but both failed during the installation, so don't tell me to use them.

0

There are 0 best solutions below

Related Questions in STRXFRM