Detect asc as the second parameter
parent
df851affda
commit
04892f1fc5
12
index.js
12
index.js
|
@ -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])
|
||||||
|
|
Loading…
Reference in New Issue