hx.sort.compare('a','b') // returns -1
hx.sort.compare('b','a') // returns 1
hx.sort.compare('a','a') // returns 0
array = ['b','c','a']
array.sort(hx.sort.compare) // returns ['a', 'b', 'c']
array = ['20','1','100']
array.sort() // returns ['1', '100', '20']
array.sort(hx.sort.compare) // returns ['1', '20', '100']
array = ['é', 'e', 'z', 'è', 'a', 'ä']
array.sort() // returns ['a', 'e', 'z', 'ä', 'è', 'é']
array.sort(hx.sort.localeCompare()) // returns ['a', 'ä', 'e', 'é', 'è', 'z']
array.sort(hx.sort.localeCompare('de')) // returns ['a', 'ä', 'e', 'é', 'è', 'z']
array.sort(hx.sort.localeCompare('sv')) // returns ['a', 'e', 'é', 'è', 'z', 'ä']
locale
and options
parameters. locale
and options
parameters can be found on the svCompare = hx.sort.localeCompare('sv')
array.sort(svCompare)
function(a, b){
return hx.sort.localeCompare(a, b, 'sv')
};
hx.sort
methods have been renamed to explict functions: hx.compare
, hx.compareNullsLast
, hx.localeCompare
array = ['20','1','100']
array.sort() // returns ['1', '100', '20']
array.sort(hx.sort.compare) // returns ['1', '20', '100']
locale
and options
parameters. locale
and options
parameters can be found on the svCompare = hx.sort.localeCompare('sv')
array.sort(svCompare)
function(a, b){
return hx.sort.localeCompare(a, b, 'sv')
};
array = ['20','1','100']
array.sort() // returns ['1', '100', '20']
array.sort(hx.sort.compare) // returns ['1', '20', '100']