Wish List.SortTypeUnicode

asales

Expert
Licensed User
Longtime User
The SortType and SortTypeCaseInsensitive works fine, but not with accented characters.

If already exists I don't know how to use it.

If don't exists, I would like Case Insensitive and Unicode (to accented characters) version of SortType for Lists.
 

asales

Expert
Licensed User
Longtime User
Both methods should work properly with any characters. Can you post an example that doesn't work for you?
Hi Erel.
I tried with this example:
https://www.b4x.com/android/forum/threads/ultimatelistview-example.46277/
Did not works with accented characters in the name of apps installed in device and use List.SortType.

I made a similar (and simple) example, in attached.
There are 2 database in file assets: cities.db and cities_noaccents.db.

If I use cities.db and SortTypeCaseInsensitive or SortType the list shows, incorrectly:
B4X:
-> SAO PAULO
Salvador
San Jose
Santiago
Sao Paulo
Singapore
Sofia
-> SÃO PAULO
-> São Paulo

The list should be shown like this (correctly):
B4X:
Salvador
San Jose
Santiago
Sao Paulo
-> SAO PAULO
-> São Paulo
-> SÃO PAULO
Singapore
Sofia
 

Attachments

  • db_city_list2.zip
    9.6 KB · Views: 188

Mahares

Expert
Licensed User
Longtime User
For your code project to work:
Replace this:
B4X:
dbCursor = dbSQL.ExecQuery("SELECT City, Country FROM Cities") ' ORDER BY City
With this:
B4X:
dbCursor = dbSQL.ExecQuery("Select City,Country  FROM Cities ORDER BY (CASE SUBSTR(City,2,1)  WHEN 'Ã'  THEN REPLACE(City,'Ã','a') " _
& " WHEN  'ã'  THEN REPLACE(City,'ã','a')  ELSE City END) COLLATE NOCASE")

Also comment or remove this line:
ListCities.SortType("CityName",True) 'Needs commneted

For your specific List question, I defer to Erel.
 

asales

Expert
Licensed User
Longtime User
Thanks @Mahares
Portuguese language has several accented characters (Ã, Á, À, Â, Ç, É, Ê, etc...) and will be a huge SQL only to sort the list correctly.
SQLite has a problem with sorted accented characters.

I hope that I can use the SortType in this case, with help of @Erel .
 

Mahares

Expert
Licensed User
Longtime User
Here is your project zipped modified to accommodate any name with with any accents. It will do exactly what you want. Please add the JavaObject library. Every code I added has this comment next to it: '1/27/15 Mahares
Please run it and let us know. And if you still want Erel to respond to you, of course he will.
 

Attachments

  • Cities_With_Accents_Sorted_Mahares012715.zip
    10 KB · Views: 182
Last edited:

asales

Expert
Licensed User
Longtime User
Here is your project zipped modified to accommodate any name with with any accents. It will do exactly what you want. Please add the JavaObject library. Every code I added has this comment next to it: '1/27/15 Mahares
Please run it and let us know. And if you still want Erel to respond to you, of course he will.
Thank you very much, @Mahares .
Very interesting modification.
Works fine.
 
Top