Skip to content

Commit 887d565

Browse files
committed
update:修复排序算法
1 parent 7043ba9 commit 887d565

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

Diff for: utils/natsort.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ function naturalCompareFactory(options) {
6161
if (isNaN(tokenA) !== isNaN(tokenB)) return isNaN(tokenA) ? ascending : descending;
6262

6363
if (unicodeRegex.test(tokenA + tokenB) && tokenA.localeCompare) {
64-
const localeComparison = tokenA.localeCompare(tokenB);
64+
// const localeComparison = tokenA.localeCompare(tokenB);
65+
const localeComparison = tokenA.localeCompare(tokenB, 'zh-CN', {numeric: true, sensitivity: 'base'});
6566
if (localeComparison !== 0) return localeComparison * ascending;
6667
}
6768

Diff for: utils/utils.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,8 @@ export function naturalSort(arr, key, customOrder = []) {
8686
}
8787

8888
// 如果都不在自定义列表中,按自然顺序排序
89-
// return aValue.localeCompare(bValue, undefined, {numeric: true, sensitivity: 'base'});
90-
91-
return naturalCompare(aValue, bValue)
89+
// return aValue.localeCompare(bValue, 'zh-CN', {numeric: true, sensitivity: 'base'});
90+
return naturalCompare(aValue, bValue);
9291
});
9392
}
9493

0 commit comments

Comments
 (0)