Merge pull request #4243 from MoMack20/master
use Intl.Collator instead of localeCompare to boost sort timepull/4276/head^2
commit
eb4406642d
|
@ -516,7 +516,8 @@ export default {
|
|||
}
|
||||
|
||||
let data = [...value];
|
||||
|
||||
|
||||
const stringCompare = new Intl.Collator(undefined, { numeric: true }).compare;
|
||||
data.sort((data1, data2) => {
|
||||
let value1 = ObjectUtils.resolveFieldData(data1, this.d_sortField);
|
||||
let value2 = ObjectUtils.resolveFieldData(data2, this.d_sortField);
|
||||
|
@ -526,7 +527,7 @@ export default {
|
|||
if (value1 == null && value2 != null) result = -1;
|
||||
else if (value1 != null && value2 == null) result = 1;
|
||||
else if (value1 == null && value2 == null) result = 0;
|
||||
else if (typeof value1 === 'string' && typeof value2 === 'string') result = value1.localeCompare(value2, undefined, { numeric: true });
|
||||
else if (typeof value1 === 'string' && typeof value2 === 'string') result = stringCompare(value1, value2);
|
||||
else result = value1 < value2 ? -1 : value1 > value2 ? 1 : 0;
|
||||
|
||||
return this.d_sortOrder * result;
|
||||
|
|
Loading…
Reference in New Issue