npm.io
2.2.0 • Published 4 years ago

natural-sort-by-key

Licence
ISC
Version
2.2.0
Deps
1
Size
34 kB
Vulns
0
Weekly
0

natural-sort-by-key

Sort array of objects by natural, human, alphanumeric order. Natural sort order is an ordering of strings in alphabetical order, except that multi-digit numbers are ordered as a single character.

__CODE_BLOCK_0__gt; npm i natural-sort-by-key

const byKey = require('natural-sort-by-key');
list.sort( byKey('flarp') )

Where list is an array of objects

let list = [
  {flarp: '10 Baz'},
  {flarp: '100 Baz'},
  {flarp: '20 Baz'},
]

More at Wikipedia

Keywords