{"name":"alpha-sort","version":"1.0.2","description":"Alphabetically sort an array of strings","license":"MIT","repository":{"type":"git","url":"https://github.com/sindresorhus/alpha-sort"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"engines":{"node":">=0.10.0"},"scripts":{"test":"node test.js"},"files":["index.js"],"keywords":["alpha","alphabet","alphabetically","sort","compare","comparator","locale","unicode","string","str"],"devDependencies":{"ava":"0.0.4"},"gitHead":"dbec941f70842c3eb229341b4b1331c734b2c812","bugs":{"url":"https://github.com/sindresorhus/alpha-sort/issues"},"homepage":"https://github.com/sindresorhus/alpha-sort","_id":"alpha-sort@1.0.2","_shasum":"8ee211fcd0b0d491164621adeb69b428950a95ed","_from":".","_npmVersion":"2.5.1","_nodeVersion":"0.12.0","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"dist":{"shasum":"8ee211fcd0b0d491164621adeb69b428950a95ed","tarball":"http://registry-npm.ywwl.com/alpha-sort/download/alpha-sort-1.0.2.tgz","integrity":"sha512-5qJgMP7MBt544eTZRjvLy9pi8bMgPHRRmGZlX/8dEPrfbvbm+348sruF8CXCC3Zzll44Oad8067HhtQfQSDLag==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIBGVJsdfiBn53hLt8h0pTHDN5atg9w8vRIpi8TRzjNJqAiEArCBmWQp0U/zH+hDG8c4UWlfJMSp2eDO5eq6WoF0uAQU="}],"size":1582,"noattachment":false,"key":"/alpha-sort/-/alpha-sort-1.0.2.tgz"},"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":1426350076688,"_cnpm_publish_time":1426350076688,"dist-tags":{"latest":"5.0.0"}}