Bug 47195 - Use language sensitive sorting for tools.cmpObjects
Use language sensitive sorting for tools.cmpObjects
Status: CLOSED FIXED
Product: UCS
Classification: Unclassified
Component: UMC (Generic)
UCS 4.3
Other Linux
: P5 normal (vote)
: UCS 4.3-1-errata
Assigned To: Johannes Keiser
Ole Schwiegert
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2018-06-14 17:12 CEST by Johannes Keiser
Modified: 2018-08-29 12:49 CEST (History)
0 users

See Also:
What kind of report is it?: Feature Request
What type of bug is this?: ---
Who will be affected by this bug?: ---
How will those affected feel about the bug?: ---
User Pain:
Enterprise Customer affected?:
School Customer affected?:
ISV affected?:
Waiting Support:
Flags outvoted (downgraded) after PO Review:
Ticket number:
Bug group (optional):
Max CVSS v3 score:
keiser: Patch_Available+


Attachments
Patch (2.98 KB, patch)
2018-06-14 17:25 CEST, Johannes Keiser
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Johannes Keiser univentionstaff 2018-06-14 17:12:55 CEST
The Grid already uses language sensitive sorting via an Intl.Collator object, that correctly sorts umlauts/accents for different locales e.g.

console.log(letterSort('de', ['a','z','ä']));
// expected output: Array ["a", "ä", "z"]

console.log(letterSort('sv', ['a','z','ä']));
// expected output: Array ["a", "z", "ä"]

and sorts nubers without leading zeros correctly e.g.
'2' < '10'


The tools.cmpObjects function which is used for sorting Trees, SelectBoxes, Policies, Apps.. should also use an Intl.Collator for sorting.
Comment 1 Johannes Keiser univentionstaff 2018-06-14 17:25:38 CEST
Created attachment 9558 [details]
Patch
Comment 2 Johannes Keiser univentionstaff 2018-08-22 16:28:47 CEST
7248d8f Bug #47195: Use Intl.Collator in tools.cmpObjects
ed0b3a5 Bug #47195: Debian changelog
4db5420 Bug #47195: YAML - add entry
a93c6d1 Bug #47195: Merge branch 'jkeiser/47195__intl.collator_for_tools.cmpObjects' into 4.3-1
402ed0a Bug #47195: Remove trailing comma
5f3954f Bug #47195: YAML - update version

Successful build
Package: univention-web
Version: 2.0.0-21A~4.3.0.201808221621
Comment 3 Ole Schwiegert univentionstaff 2018-08-28 12:12:25 CEST
Advisory&Changelog: OK
Package installed: OK
Number sorting: OK (*)
locale sorting: OK (**)

(*) Works as desired (2<10), tested with the MultiSelect in Assign classes module

(**) Works as described in Description. Tested via console

tools = require('umc/tools')
myA=[{'fn':'Anton'},{'fn':'Änton'},{'fn':'Susi'}]
myF=tools.cmpObjects({'attribute': 'fn', 'collatorLocales':'sv'})
myA.sort(myF)
-> Anton, Susi, Änton

myF=tools.cmpObjects({'attribute': 'fn', 'collatorLocales':'de'})
myA.sort(myF)
-> Anton, Änton, Susi
Comment 4 Arvid Requate univentionstaff 2018-08-29 12:49:41 CEST
<http://errata.software-univention.de/ucs/4.3/227.html>