Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hughsk/path-sort
Sort a list of file/directory paths
https://github.com/hughsk/path-sort
Last synced: 12 days ago
JSON representation
Sort a list of file/directory paths
- Host: GitHub
- URL: https://github.com/hughsk/path-sort
- Owner: hughsk
- License: other
- Created: 2013-08-07T12:02:28.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2016-09-15T19:44:35.000Z (about 8 years ago)
- Last Synced: 2024-10-17T16:41:12.743Z (22 days ago)
- Language: JavaScript
- Size: 109 KB
- Stars: 15
- Watchers: 4
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# path-sort [![stable](http://hughsk.github.io/stability-badges/dist/stable.svg)](http://github.com/hughsk/stability-badges) #
Sort a list of file/directory paths, such that something like this:
``` javascript
[
'a/world'
, 'a/lib/index.js'
, 'b/package.json'
, 'b/lib/3/index.js'
, 'b/lib/2/README.js'
, 'a/hello'
, 'b/lib/2/index.js'
, 'a/lib/README.md'
, 'b/lib/3/README.js'
, 'c'
]
```Becomes something like this:
``` javascript
[
'a/hello'
, 'a/world'
, 'a/lib/index.js'
, 'a/lib/README.md'
, 'b/package.json'
, 'b/lib/2/index.js'
, 'b/lib/2/README.js'
, 'b/lib/3/index.js'
, 'b/lib/3/README.js'
, 'c'
]
```## Installation ##
``` bash
npm install path-sort
```## Usage ##
### `require('path-sort')(files[, sep])` ###
Takes an array of `filenames` with an optional delimiter (`sep`), returning a
sorted copy.### `require('path-sort').standalone([sep])` ###
Returns a `Array.prototype.sort`-friendly method. It's a little slower but
easier to use in some cases.``` javascript
var sorter = require('path-sort').standalone('/')array = array.sort(sorter)
```