Detect asc as the second parameter
parent
df851affda
commit
04892f1fc5
8
index.js
8
index.js
|
@ -9,9 +9,15 @@ const sortby = (properties) => (a, b) => {
|
|||
const property = properties[i]
|
||||
|
||||
let order = -1
|
||||
if (i + 1 < properties.length && properties[i + 1] === 'desc') {
|
||||
if (i + 1 < properties.length) {
|
||||
const next = properties[i + 1]
|
||||
|
||||
if (next === 'desc') {
|
||||
order = 1
|
||||
i++
|
||||
} else if (next === 'asc') {
|
||||
i++
|
||||
}
|
||||
}
|
||||
|
||||
const compare = collator.compare(a[property], b[property])
|
||||
|
|
Loading…
Reference in New Issue