Univention Bugzilla – Bug 47195
Use language sensitive sorting for tools.cmpObjects
Last modified: 2018-08-29 12:49:41 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.
Created attachment 9558 [details] Patch
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
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
<http://errata.software-univention.de/ucs/4.3/227.html>