tri des cols, on transforme en lowercase

This commit is contained in:
Christophe 2020-03-10 22:58:59 +01:00
parent 4e21e5a168
commit 73edf728a7
2 changed files with 5 additions and 1 deletions

View file

@ -26,7 +26,9 @@ const orderBy = (arr, props, orders) =>
arr.sort((a, b) =>
props.reduce((acc, prop, i) => {
if (acc === 0) {
const [p1, p2] = orders && orders[i] === 'desc' ? [b[prop], a[prop]] : [a[prop], b[prop]];
let [p1, p2] = orders && orders[i] === 'desc' ? [b[prop], a[prop]] : [a[prop], b[prop]];
p1 = typeof p1 === 'string' ? p1.toLowerCase() : p1;
p2 = typeof p2 === 'string' ? p2.toLowerCase() : p2;
acc = p1 > p2 ? 1 : p1 < p2 ? -1 : 0;
}
return acc;

View file

@ -43,6 +43,8 @@ var orderBy = function orderBy(arr, props, orders) {
p1 = _ref2[0],
p2 = _ref2[1];
p1 = typeof p1 === 'string' ? p1.toLowerCase() : p1;
p2 = typeof p2 === 'string' ? p2.toLowerCase() : p2;
acc = p1 > p2 ? 1 : p1 < p2 ? -1 : 0;
}