therewillbecode / regex-sort

Sort an array of strings using regex patterns.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

regex-sort

PayPal AMA Version Downloads Get help on Codementor

Sort an array of strings using regex patterns.

☁️ Installation

$ npm i --save regex-sort

📋 Example

const regexSort = require("regex-sort");

let result = regexSort([
    "path/to/index.json",
    "path/to/foo.js",
    "path/to/index.min.js",
    "path/to/index.js"
], [
    /index\.(min\.)?js$/
  , /index\.json$/
]);

console.log(result);
// [ 'path/to/index.js',
//   'path/to/index.min.js',
//   'path/to/index.json',
//   'path/to/foo.js' ]

📝 Documentation

regexSort(list, patterns)

Sort an array of strings using regex patterns.

Params

  • Array list: An array of strings.
  • Array patterns: An array of regular expressions used in sorting.

Return

  • Array A new array containing the sorted elements.

😋 How to contribute

Have an idea? Found a bug? See how to contribute.

📜 License

MIT © Ionică Bizău

About

Sort an array of strings using regex patterns.

License:MIT License


Languages

Language:JavaScript 100.0%