{"name":"alpha-sort","version":"5.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"},"type":"module","exports":"./index.js","engines":{"node":">=12"},"scripts":{"test":"xo && ava && tsd"},"keywords":["alpha","alphabet","alphabetically","lexicographically","sort","compare","comparator","order","locale","unicode","string","intl","collator","natural"],"devDependencies":{"ava":"^3.15.0","tsd":"^0.14.0","xo":"^0.38.2"},"gitHead":"2b807cc8e12ef6ff49e53149aa1e3c78445d0e34","bugs":{"url":"https://github.com/sindresorhus/alpha-sort/issues"},"homepage":"https://github.com/sindresorhus/alpha-sort#readme","_id":"alpha-sort@5.0.0","_nodeVersion":"15.12.0","_npmVersion":"6.14.10","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"integrity":"sha512-ObQ58fJyEEYr7n91itdT/N4LYmg6H/HehNHIvsTL9byMLYf3acJaLpvc+/KnvNDQVX5LmACETJAtWLXA9GUTmw==","shasum":"83dceebaf1c838eb45e75c03b45d0d1f53724f8c","tarball":"http://registry-npm.ywwl.com/alpha-sort/download/alpha-sort-5.0.0.tgz","fileCount":6,"unpackedSize":9969,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgcF9YCRA9TVsSAnZWagAALp8P/08n4We7JC8VC3XYB9BA\nOza7htCjxWmUC5htSmMv3NOUOaKLHnJA0P3swCp6SnJghBPgI8+7vCjrGj8r\nvwWKO1/NAfT7P2mms+BhhzYFKinUc+32dNUGxQVBZ5zpLO4jnNuA+BqfOC95\nqHslE6Zvl1XLKV2UokxuIZNTAD3QU12Zcx7JeXO0MjMta1vTeE7ACqNIVhY1\n3xiJEMX5P6EL8jf1Zkjqx4UmpYFusx/vcyEv5Wsed8PnHQNVOrVtLhd5nBaw\nxRZpw0Xv3KN6qKj+9kRbT92vdU1M9pHZUn9FNw6c2R8QyhQ5WiufMWuxIsv0\nisqRTF/1Okf5gHjHQVJLhGn4In1QumpuppRCz3e754uyCAwCZF7aBgXkUwSF\nIVYXqLG5u3JryFBWHUhin2Ssanns7p8Za83NjwPO8alv+EbYSqetsWAUZt6U\nwEbaiVV/wIs1uKZktnTvDJOJcrZgr3ytH1448IfSYKVl53Vcz6GCTFtgcCss\nSvB5C34D8jBfVaMmn74d+1ap0nsXKx2QpwIYY/O7+LooFD0nxvj9ySO4hrKO\nrmzlPWTraAfDva8YpdRl7UXuP1JOKiPfgdwMqA0bV12AziiwmPpRotWUn7/j\nskHC6Hn3uoEHbpuEFmakR/1CdtNnfrdbEFHFjkh4o7U4Nzjd3meyQs+quNzv\nWVrn\r\n=TZlF\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCYZB+t75nWwY3yxFUe9bVXIWGiGZeUBQUOx9ojfdfvtQIgBvdkmr9si78eZSnOQae2+cawVXtlW4G8VlL/AGUpAlg="}],"size":3439,"noattachment":false,"key":"/alpha-sort/-/alpha-sort-5.0.0.tgz"},"directories":{},"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/alpha-sort_5.0.0_1617977176445_0.37077796357990134"},"_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":1617977176563,"_cnpm_publish_time":1617977176563,"dist-tags":{"latest":"5.0.0"}}