sort-with-exclusions
v1.0.2
Published
Sort that allows you to exclude elements from being reordered
Downloads
71
Maintainers
Readme
Sort with exclusions
Allows you to sort an array while using a callback to determine which elements to exclude. Uses Array.sort under the hood. No external dependencies.
Example
const sortWithExclusions = require('sort-with-exclusions');
sortWithExclusions([3, 2, 1], value => value === 3); // => [3, 1, 2]
// Using an Array.sort comparison function
sortWithExclusions([3, 2, 1], value => value == 1, (a, b) => a - b); // => [2, 3, 1]
Installation
$ npm install sort-with-exclusions
License
MIT © Andy Hansen