path-sort2
Sort a list of file/directory paths, such that something like this:
Example
const pathSort = ; let files = 'a/c' 'a/a/a' 'b/b' 'b/a/2/a' 'b/a/1/b' 'a/b' 'b/a/1/a' 'a/a/b' 'b/a/2/b' 'c'; let sortedFiles = ;// [// 'a/b',// 'a/c',// 'a/a/a',// 'a/a/b',// 'b/b',// 'b/a/1/a',// 'b/a/1/b',// 'b/a/2/a',// 'b/a/2/b',// 'c',// ]
Install
npm install path-sort2
Usage
const pathSort = ; ; // sorted files; // custom seperator (defaults to `path.sep`) files; // sorted filesfiles; // custom seperator (defaults to `path.sep`)
Note: Using
pathSort.standalone()
is a little bit slower, but is sometimes more convenient.