feat(VnSelect): order data equal salix #918

Merged
alexm merged 3 commits from warmFix_order_equalSalix into dev 2024-11-13 06:48:56 +00:00
1 changed files with 4 additions and 3 deletions
Showing only changes of commit 8269037faa - Show all commits

View File

@ -1,4 +1,5 @@
function orderData(data, order) {
if (typeof order === 'function') return data.sort(data);
if (typeof order === 'string') order = [order];
if (Array.isArray(order)) {
let orderComp = [];
@ -12,13 +13,13 @@ function orderData(data, order) {
}
return data.sort((a, b) => sortFunc(a, b, orderComp));
alexm marked this conversation as resolved
Review

Para ayudar en la legibilidad, mover esta linea a antes del segundo if

Para ayudar en la legibilidad, mover esta linea a antes del segundo if
} else if (typeof order === 'function') return data.sort(data);
}
return data;
}
function sortFunc(a, b, order) {
alexm marked this conversation as resolved
Review

let {field, way} ??

let {field, way} ??
for (let i of order) {
let compRes = compareFunc(a[i.field], b[i.field]) * i.way;
for (let { field, way } of order) {
let compRes = compareFunc(a[field], b[field]) * way;
if (compRes !== 0) return compRes;
}