Open wfdd opened 8 years ago
The built in locale
is probably good enough? e.g. http://stackoverflow.com/a/1098160/669631
>>> print sorted([u'Όλοι Στον Αγώνα', u'Κόμμα για τα Ζώα Κύπρου'])[0]
Όλοι Στον Αγώνα
>>> import locale
>>> locale.setlocale(locale.LC_COLLATE, 'el_GR.UTF-8')
'el_GR.UTF-8'
>>> print sorted([u'Όλοι Στον Αγώνα', u'Κόμμα για τα Ζώα Κύπρου'], cmp=locale.strcoll)[0]
Κόμμα για τα Ζώα Κύπρου
Alternatively, if this is being displayed directly from the database call, the sorting could be done by the database query assuming its locale is set up okay.
Even with the default English locale it sorts them in the right order on Ubuntu:
ynr=> SHOW LC_COLLATE;
lc_collate
-------------
en_US.UTF-8
(1 row)
ynr=> SELECT id,name from popolo_organization
ynr-> WHERE name IN ('Όλοι Στον Αγώνα','Κόμμα για τα Ζώα Κύπρου')
ynr-> ORDER BY name;
id | name
----+-------------------------
16 | Κόμμα για τα Ζώα Κύπρου
20 | Όλοι Στον Αγώνα
(2 rows)
Though YMMOV for languages that use the Latin script and UTF-8 collations don't work on BSD systems.
See [1], where 'Όλοι Στον Αγώνα' should've come after 'Κόμμα για τα Ζώα Κύπρου'. I suggest adding an (ASCII) sort key to the organization extra or importing ICU for sorting, or both.