Contacts for Android: wrong local sorting / sorting

This is my problem: I am writing an alternative application for contacts, which is indicated for working with LOT of different languages ​​and alphabets. When querying for names in my native language, Swedish, names using umlaut characters are sorted illogically to me, but logically for unicode I assume:

Must be / Swedish style: A, B, C, ..., Z, Å, Ä, ....

Query result: A, Å, Ä, B, ..., N, O, ..., P, ...

I guess this will be a problem in any language that is different from the Latin alphabet. All the tests that I have done are on the emulator. My development team is making changes to the structure, so low-level answers are also welcome.

Uri uri = ContactsContract.Contacts.CONTENT_URI; String[] projection = new String[] { ContactsContract.Contacts._ID, ContactsContract.Contacts.DISPLAY_NAME, ContactsContract.Contacts.PHOTO_ID }; String selection = ContactsContract.Contacts.IN_VISIBLE_GROUP + " = '1'"; String sortOrder = ContactsContract.Contacts.DISPLAY_NAME + " COLLATE LOCALIZED ASC"; mCursor = managedQuery(uri, projection, null, null, sortOrder); 

Update: we are currently exploring this track: Sorting an array of strings , TBC ... I also added it as a problem in Google Code.

+4
source share
1 answer

Gaah. It looks like this:

running the following code in vanilla Java (SE-1.6) generates the desired result:

 String strings[] = {"Åke", "Äskil", "Otto", "Adam", "Örjan", "Palle", "Nisse"}; Locale locale = new Locale("sv", "SE"); Collator collator = java.text.Collator.getInstance(locale); java.util.Arrays.sort(strings, collator); 

But the same code in Android does NOT work for me.

Edit: I made an issue of this on the Google Google Code website, it was commented by a reviewer.

+1
source

All Articles