Sort by human number 1, ..., 9, 10 and not 1,10, 2

master
Frédéric Matte 2023-09-19 11:47:05 -04:00
parent a821e706cb
commit 3b0a56ba50
1 changed files with 5 additions and 2 deletions

View File

@ -11,8 +11,11 @@ const sortby = (properties) => (a, b) => {
i++ i++
} }
if (a[property] < b[property]) return order const collator = new Intl.Collator('en', { numeric: true, sensitivity: 'base' })
if (a[property] > b[property]) return -order const compare = collator.compare(a[property], b[property])
if (compare > 0) return order
if (compare < 0) return -order
} }
return 0 return 0