diff --git a/index.js b/index.js index 4dc4755..af4c5e8 100644 --- a/index.js +++ b/index.js @@ -1,4 +1,6 @@ const sortby = (properties) => (a, b) => { + const collator = new Intl.Collator('en', { numeric: true, sensitivity: 'base' }) + // if items is {prop1:value1, prop2:value2} // then sort(['prop1', 'desc', 'prop2']) // will sort by prop1 desc and prop2 @@ -11,7 +13,6 @@ const sortby = (properties) => (a, b) => { i++ } - const collator = new Intl.Collator('en', { numeric: true, sensitivity: 'base' }) const compare = collator.compare(a[property], b[property]) if (compare < 0) return order if (compare > 0) return -order