{"name":"alpha-sort","version":"4.0.0","description":"Alphabetically sort an array of strings","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/alpha-sort.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"engines":{"node":">=10"},"scripts":{"test":"xo && ava && tsd"},"keywords":["alpha","alphabet","alphabetically","lexicographically","sort","compare","comparator","order","locale","unicode","string","intl","collator","natural"],"devDependencies":{"ava":"^2.4.0","tsd":"^0.14.0","xo":"^0.36.1"},"gitHead":"5fe95edbb7aa4ab7e567f44a53bb7dbb9149398d","bugs":{"url":"https://github.com/sindresorhus/alpha-sort/issues"},"homepage":"https://github.com/sindresorhus/alpha-sort#readme","_id":"alpha-sort@4.0.0","_nodeVersion":"15.5.0","_npmVersion":"6.14.10","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"integrity":"sha512-fIzG0HQOM/WcoWTPp7sttwVOEB5r1QdVrwHf+ef2RdPWfJbA9c6YB4MFyMMLaTetCLn3Dz3j7bJnOdloJa9g9A==","shasum":"4bff5b77892f2c853beaf4339e11ec5adb9cdfee","tarball":"http://registry-npm.ywwl.com/alpha-sort/download/alpha-sort-4.0.0.tgz","fileCount":6,"unpackedSize":10063,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf7DIDCRA9TVsSAnZWagAAr4sP/2h+rHKrg8xQ++Otpbhi\nkDi6bmpuOeA1ht71nADsArtugqiijZqB+yo9Y8WWVPx5EZVC4jDx8wegZ0Sd\nPp2Of37JmI90TbfsrGxYMUadm8vUOtg5LUIMQ9wMr0flyuMBbvy1wxMI0+lc\nmLk8PvDKFX66PprMmYFOL26b8JlC2v2Xgg4ct8FeDjfjUF8yclAXJn6FPv3y\nwY7ZjQtfWlaA8zeK46y/dN2cRo36Xc6RC91tCDxh/EO2C/rpK+z7uqSKZQ1U\nWyWDwdteVq3CKM8b4+rHDPUXVY2Phc2DYhQoH4mGOm4RqIMKnHT+RBz/FVvO\nm/cRv9HWLYzdBge0gBeErxQ2lJauqPDNCDM6ycx0Nz51jVJxEOGX88hamDfH\nyhyCRAKHhyV3hzfplkh3x9qK3RVUJPtBE/kOWB+T5PRMQ6bFsNX0MEL/OdcP\nowcbyU51bKcS+QZ8DhG90c7OoEszJoAFAqumL+F9z3Z6JqFVMRA+jCk7pNdz\nJJ0PpkCu++51t5mDAfoRb7Vy5QEQTcuI+0mSrs2lvbp0kVhPRJPBvm5PJWw5\nmn7NUOKfp5vZS22xPfRIcg8ssvpAmoCkgXMhpi2otFzRbx2BF+CLaJbjOveR\nlWSSwVjJ1Tx9NoOprdQWIUPQ6qVuN7mICAYCVwSg+xihagf8irsVCxHtswbi\nclMJ\r\n=+HP1\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCIqEhDZLr1lX+Bdy7PX2B0aDcrRsw1x2LWZgpetQw2BQIgTIwDrH7bPYmWCSUAJ/KHRLXWYH0e6phXmPiWhoxZkyQ="}],"size":3448,"noattachment":false,"key":"/alpha-sort/-/alpha-sort-4.0.0.tgz"},"directories":{},"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/alpha-sort_4.0.0_1609314819101_0.07043103071474421"},"_hasShrinkwrap":false,"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":1609314819242,"_cnpm_publish_time":1609314819242,"dist-tags":{"latest":"5.0.0"}}