nextcloud / contacts

📇 Contacts app for Nextcloud
https://apps.nextcloud.com/apps/contacts
GNU Affero General Public License v3.0
558 stars 168 forks source link

Nextcloud Contacts groups are not sorted properly #3057

Open martinhankovec opened 1 year ago

martinhankovec commented 1 year ago

Describe the bug

Groups with UTF8 characters in names are sorted in bad order, characters with diacritics are at the end (see SOkA Písek, SOkA České Budějovice on the picture): contacts Right order of groups: SOA v Třeboni SOA v Třeboni - odd.... SOkA České Budějovice (Č sorted as C!) SOkA Český Krumlov (Č sorted as C!) SOkA Jindřichův Hradec SOkA Písek (í sorted as i!) SOkA Prachatice SOkA Strakonice SOkA Tábor

Steps to reproduce

Try to add these groups and see displayed order: SOkA České Budějovice SOkA Český Krumlov SOkA Jindřichův Hradec SOkA Písek SOkA Prachatice SOkA Strakonice

Expected behavior

Sort group names with UTF-8 characters correctly

Actual behavior

Now are the names of groups sorted in bad order, maybe latin1 and not UTF-8?

Contact version

4.2.2

Operating system

CentOS 7

PHP engine version

PHP 7.4

Web server

Apache (supported)

Database

PostgreSQL

Additional info

No response

ChristophWurst commented 1 year ago

I appears groups are sorted at https://github.com/nextcloud/contacts/blob/eb035630e2ca67195da30371c0403e6873c64d8c/src/components/AppNavigation/RootNavigation.vue#L334 using https://www.npmjs.com/package/string-natural-compare.

If I look at https://github.com/nwoltman/string-natural-compare/issues/11 I get the impression that for our case it would be more clever to use the browser's compare API that respects the locale.

martinhankovec commented 1 year ago

Yes. naturalCompare solves the problem with order of numbers (1, 10, 100 etc.), but it seems not working well with locale. In my opinion the problem with locales in group names is much more serious than the possible problem of bad order with numbered groups (Group 1, Group 10, Group 2 etc.). Thanks a lot.

xmsz-stu commented 2 months ago

is there any workaround?