稳定性:排序时相等的值不会触发交换

This commit is contained in:
huayj 2019-08-23 14:55:58 +08:00
parent e1dc400823
commit 863ca7e905
1 changed files with 2 additions and 2 deletions

View File

@ -277,13 +277,13 @@ export default function sort(Table, Icon) {
// 默认的比较函数,即字符串比较函数
defaultSortFn = (key) => (a, b)=> {
return a[key] > b[key] ? 1 : -1;
return a[key] >= b[key] ? 1 : -1;
}
// 数值比较函数
numberSortFn = (key) => (a, b)=> {
let numberA = parseFloat(a[key]);
let numberB = parseFloat(b[key]);
return numberA > numberB ? 1 : -1;
return numberA >= numberB ? 1 : -1;
}
_flatToColumn(flatColumns){