Create one collator per run
parent
f4157d9262
commit
9a93035409
5
index.js
5
index.js
|
@ -1,10 +1,12 @@
|
||||||
const sortby = (...properties) => (a, b) => {
|
|
||||||
|
const sortby = (...properties) => {
|
||||||
// 'base' treat accent as there base character
|
// 'base' treat accent as there base character
|
||||||
const collator = new Intl.Collator('en', { numeric: true, sensitivity: 'base' })
|
const collator = new Intl.Collator('en', { numeric: true, sensitivity: 'base' })
|
||||||
|
|
||||||
// if items is {prop1:value1, prop2:value2}
|
// if items is {prop1:value1, prop2:value2}
|
||||||
// then sort(['prop1', 'desc', 'prop2'])
|
// then sort(['prop1', 'desc', 'prop2'])
|
||||||
// will sort by prop1 desc and prop2
|
// will sort by prop1 desc and prop2
|
||||||
|
return (a, b) => {
|
||||||
for (let i = 0; i < properties.length; i++) {
|
for (let i = 0; i < properties.length; i++) {
|
||||||
const property = properties[i]
|
const property = properties[i]
|
||||||
|
|
||||||
|
@ -28,5 +30,6 @@ const sortby = (...properties) => (a, b) => {
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export { sortby }
|
export { sortby }
|
Loading…
Reference in New Issue