Skip to content

Sort that allows you to exclude elements from being reordered

License

Notifications You must be signed in to change notification settings

andylhansen/sort-with-exclusions

Repository files navigation

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

About

Sort that allows you to exclude elements from being reordered

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published