部分修改

This commit is contained in:
kclf
2022-12-05 01:26:17 +08:00
parent 3fd9632adc
commit 14568127bf
16 changed files with 2065 additions and 418 deletions

View File

@@ -57,19 +57,16 @@ export function deepCloneFilterString(obj, fillterKeys) {
return obj;
}
export function sortBy(arr, ...keys) {
export function sortBy(arr, key) {
return arr.sort((x, y) => {
for (const key of keys) {
const valueX = typeof key === "function" ? key(x) : x[key];
const valueY = typeof key === "function" ? key(y) : y[key];
if (valueX > valueY) {
return 1;
}
if (valueX < valueY) {
return -1;
}
const valueX = parseInt(x[key]);
const valueY = parseInt(y[key]);
if (valueX > valueY) {
return 1;
}
if (valueX < valueY) {
return -1;
}
return 0;
});
}