{"name":"alpha-sort","version":"2.0.0","description":"Alphabetically sort an array of strings","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/alpha-sort.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"engines":{"node":">=4"},"scripts":{"test":"xo && ava"},"files":["index.js"],"keywords":["alpha","alphabet","alphabetically","sort","compare","comparator","locale","unicode","string","str","intl","collator"],"devDependencies":{"ava":"*","xo":"*"},"xo":{"esnext":true},"gitHead":"36226331ec495cbb00741d72ad2c6aadd9b152c7","bugs":{"url":"https://github.com/sindresorhus/alpha-sort/issues"},"homepage":"https://github.com/sindresorhus/alpha-sort#readme","_id":"alpha-sort@2.0.0","_shasum":"95b93d635f48949455967f07a1c7078c787b099d","_from":".","_npmVersion":"2.15.11","_nodeVersion":"4.6.2","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"95b93d635f48949455967f07a1c7078c787b099d","tarball":"http://registry-npm.ywwl.com/alpha-sort/download/alpha-sort-2.0.0.tgz","integrity":"sha512-SWQohiSsn7HPQCF4mq9r1sGkhb2dMNNYXxvUApCba/XPZGqRMbS7xBz/XMad0yJf2SgrYD6Rgq7CSX8yjtVg8w==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIBvQeXcWlV2R0Pz0yKdtsFiy2FugjS/yqYvxuE/AD4u8AiEA2f760ilhOWWHJ16JvD61RgYgGynEsnUmfZ0C9W234K4="}],"size":1602,"noattachment":false,"key":"/alpha-sort/-/alpha-sort-2.0.0.tgz"},"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/alpha-sort-2.0.0.tgz_1481970619342_0.04041515965946019"},"directories":{},"readme":"# alpha-sort\n\n> Alphabetically sort an array of strings\n\nWith correct sorting of unicode characters. Supports [natural sort order](https://en.wikipedia.org/wiki/Natural_sort_order) with an option.\n\n## Install\n\n```\n$ npm install alpha-sort\n```\n\n## Usage\n\n```js\nimport alphaSort from 'alpha-sort';\n\n['b', 'a', 'c'].sort(alphaSort());\n//=> ['a', 'b', 'c']\n\n['b', 'a', 'c'].sort(alphaSort({descending: true}));\n//=> ['c', 'b', 'a']\n\n['B', 'a', 'C'].sort(alphaSort({caseInsensitive: true}));\n//=> ['a', 'B', 'C']\n\n['file10.txt', 'file2.txt', 'file03.txt'].sort(alphaSort({natural: true}));\n//=> ['file2.txt', 'file03.txt', 'file10.txt']\n```\n\n## API\n\n### alphaSort(options?)\n\nGet a comparator function to be used as argument for [`Array#sort`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort).\n\n#### options\n\nType: `object`\n\n##### descending\n\nType: `boolean`\\\nDefault: `false`\n\nWhether or not to sort in descending order.\n\n##### caseInsensitive\n\nType: `boolean`\\\nDefault: `false`\n\nWhether or not to sort case-insensitively.\n\nNote: If two elements are considered equal in the case-insensitive comparison, the tie-break will be a standard (case-sensitive) comparison. Example:\n\n```js\nimport alphaSort from 'alpha-sort';\n\n['bar', 'baz', 'Baz'].sort(alphaSort({caseInsensitive: true}));\n//=> ['bar', 'Baz', 'baz']\n```\n\n##### natural\n\nType: `boolean`\\\nDefault: `false`\n\nWhether or not to sort using [natural sort order](https://en.wikipedia.org/wiki/Natural_sort_order) (such as sorting `10` after `2`).\n\nNote: If two elements are considered equal in the natural sort order comparison, the tie-break will be a standard (non-natural) comparison. Example:\n\n```js\nimport alphaSort from 'alpha-sort';\n\n['file10.txt', 'file05.txt', 'file0010.txt'].sort(alphaSort({natural: true}));\n//=> ['file05.txt', 'file0010.txt', 'file10.txt']\n```\n\n##### preprocessor\n\nType: `function`\\\nDefault: `undefined`\n\nA custom function that you can provide to manipulate the elements before sorting. This does not modify the values of the array; it only interferes in the sorting order.\n\nThis can be used, for example, if you are sorting book titles in English and want to ignore common articles such as `the`, `a` or `an`:\n\n```js\nimport alphaSort from 'alpha-sort';\n\n['The Foo', 'Bar'].sort(alphaSort({\n\tpreprocessor: title => title.replace(/^(?:the|a|an) /i, '')\n}));\n//=> ['Bar', 'The Foo']\n```\n\nNote: If two elements are considered equal when sorting with a custom preprocessor, the tie-break will be a comparison without the custom preprocessor.\n\n## Related\n\n- [num-sort](https://github.com/sindresorhus/num-sort) - Sort an array of numbers\n","publish_time":1481970619960,"_cnpm_publish_time":1481970619960,"dist-tags":{"latest":"5.0.0"}}