JSPM

path-sort

0.1.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 8282
  • Score
    100M100P100Q119690F
  • License MIT

Sort a list of file/directory paths

Package Exports

  • path-sort

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (path-sort) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

path-sort stable

Sort a list of file/directory paths, such that something like this:

[
  '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:

[
  '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

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.

var sorter = require('path-sort').standalone('/')

array = array.sort(sorter)