Detect asc as the second parameter

master
Frédéric Matte 2023-09-29 00:09:11 -04:00
parent df851affda
commit 04892f1fc5
1 changed files with 9 additions and 3 deletions

View File

@ -9,9 +9,15 @@ const sortby = (properties) => (a, b) => {
const property = properties[i] const property = properties[i]
let order = -1 let order = -1
if (i + 1 < properties.length && properties[i + 1] === 'desc') { if (i + 1 < properties.length) {
order = 1 const next = properties[i + 1]
i++
if (next === 'desc') {
order = 1
i++
} else if (next === 'asc') {
i++
}
} }
const compare = collator.compare(a[property], b[property]) const compare = collator.compare(a[property], b[property])