views:

32

answers:

1

How to use Query.order() on string properties containing non-english characters so entities where fetched in correct order?

Query.order is oddly putting any non-english characters on the end of the list, like this:

Dolnośląskie
Kujawsko-Pomorskie
Lubelskie
Lubuskie
Mazowieckie
Małopolskie <- incorrect order
Opolskie
Podkarpackie
Podlaskie
Pomorskie
Warmińsko-Mazurskie
Wielkopolskie
Zachodniopomorskie
Łódzkie <- incorrect order
Śląskie <- incorrect order
Świętokrzyskie <- incorrect order

Where the correct roder for this set shoul be:

Dolnośląskie
Kujawsko-Pomorskie 
Łódzkie
Lubelskie
Lubuskie
Małopolskie
Mazowieckie
Opolskie
Podkarpackie
Podlaskie
Pomorskie
Śląskie
Świętokrzyskie
Warmińsko-Mazurskie
Wielkopolskie
Zachodniopomorskie

Is there a way around that? Other than putting another property with English normalized string values just for ordering?

+5  A: 

Normalizing the strings into a separate property is the only solution to what you want; they're sorted by unicode codepoints, and the letters that are part of ASCII have much lower values than non-ASCII characters.

Wooble