nat-sort
A human sort, either as a module or CLI.
Example
As a library:
var nsort = var unsorted = 'c' 'The A' 'b' // use nsort directly with an array // ['The A', 'b', 'c'] // or use it as a comparatorunsorted // ['The A', 'b', 'c']
With the command line:
$ npm install -g nat-sort # These two commands are functionally equivalent: $ cat newline-delimited-unsorted.txt | nsort > sorted.txt$ nsort newline-delimited-unsorted.txt > sorted.txt $ nsort --help # output a help message $ cat unsorted-films.txtBlue Submarine No. 6 Sphere 2010 Capricorn One The Amittyville Horror Dr. Strangelove Space Battleship Yamato Death Race 2000 Moon Ju-on: The Grudge The Andromeda Strain House on Haunted Hill Solaris The Man Who Fell to Earth The Omega Man Das Millionenspiel House on Haunted Hill Logan's Run (1976) $ nsort unsorted-films.txt2010 (1984)The Amittyville Horror (1979)The Andromeda Strain (1971)Blue Submarine No. 6 (1998)Capricorn One (1977)Das Millionenspiel (1970)Death Race 2000 (1975)Dr. Strangelove (1964)House on Haunted Hill (1959)House on Haunted Hill (1999)Ju-on: The Grudge (2002)Logan's Run The Man Who Fell to Earth Moon The Omega Man Solaris Space Battleship Yamato Sphere
Caveats
- There are no options at the moment; there may be some in a future version
- The sort function expects ASCII text only
- This is certainly not performant, it was designed for a very specific purpose, and will probably choke on very large data sets.
License
MIT. See LICENSE for details.