Pull sort/compare utils from PrimeReact

This commit is contained in:
FlipWarthog 2023-10-05 22:00:36 -04:00
parent c6cd944735
commit 4d6a272795
9 changed files with 55 additions and 32 deletions

View file

@ -429,7 +429,7 @@ export default {
},
sortNodesSingle(nodes) {
let _nodes = [...nodes];
const comparer = new Intl.Collator(undefined, { numeric: true }).compare;
const comparer = ObjectUtils.localeComparator();
_nodes.sort((node1, node2) => {
const value1 = ObjectUtils.resolveFieldData(node1.data, this.d_sortField);
@ -472,7 +472,7 @@ export default {
return this.d_multiSortMeta.length - 1 > index ? this.multisortField(node1, node2, index + 1) : 0;
} else {
if ((typeof value1 === 'string' || value1 instanceof String) && (typeof value2 === 'string' || value2 instanceof String))
return this.d_multiSortMeta[index].order * new Intl.Collator(undefined, { numeric: true }).compare(value1, value2);
return this.d_multiSortMeta[index].order * ObjectUtils.localeComparator().compare(value1, value2);
else result = value1 < value2 ? -1 : 1;
}
}