{"name":"sort-array","author":{"name":"Lloyd Brookes","email":"75pound@gmail.com"},"contributors":[{"name":"Ben Vickers","email":"bjvickers@protonmail.com"}],"version":"3.0.0-1","description":"Sort an array of objects by any property value, at any depth, in any custom order.","repository":{"type":"git","url":"git+https://github.com/75lb/sort-array.git"},"license":"MIT","main":"dist/index.js","module":"index.mjs","keywords":["sort","by","array","recordset","objects","sorted","asc","desc"],"engines":{"node":">=8"},"scripts":{"lint":"standard --fix index.mjs test/*.js","test":"npm run dist && test-runner test/*.js","docs":"jsdoc2md -t README.hbs index.js > README.md; echo","dist":"rollup -f umd -o dist/index.js -n sortArray index.mjs"},"dependencies":{},"devDependencies":{"jsdoc-to-markdown":"^5.0.1","rollup":"^1.20.3","standard":"^14.1.0","test-runner":"^0.6.0"},"readme":"[![view on npm](http://img.shields.io/npm/v/sort-array.svg)](https://www.npmjs.org/package/sort-array)\n[![npm module downloads](http://img.shields.io/npm/dt/sort-array.svg)](https://www.npmjs.org/package/sort-array)\n[![Build Status](https://travis-ci.org/75lb/sort-array.svg?branch=master)](https://travis-ci.org/75lb/sort-array)\n[![Dependency Status](https://badgen.net/david/dep/75lb/sort-array)](https://david-dm.org/75lb/sort-array)\n[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](https://github.com/feross/standard)\n\n<a name=\"module_sort-array\"></a>\n\n## sort-array\nSort an array of objects or primitives, by any property value, in any combindation of ascending, descending, custom or calculated order.\n\n**Example**  \n```js\nconst sortBy = require('sort-array')\n```\n<a name=\"exp_module_sort-array--sortBy\"></a>\n\n### sortBy(recordset, sortBy, sortTypes, [namedConfigs]) ⇒ <code>Array</code> ⏏\n**Kind**: Exported function  \n\n| Param | Type | Description |\n| --- | --- | --- |\n| recordset | <code>Array</code> | Input array of objects or primitive values. |\n| sortBy | <code>Array.&lt;(string\\|function())&gt;</code> | One or more property expressions to sort by. Expressions may be strings which refer to properties in the input array; they may be strings which refer to properties in the optional `namedConfigs.namedComputedProps` parameter; or they may be inline functions which dynamically calculate values for each property in the input array. |\n| sortTypes | <code>Array.&lt;(string\\|Array.&lt;\\*&gt;)&gt;</code> | The sort types for each of the sortBy expressions. Values may be 'asc', 'desc', an array of custom values, and strings which refer to properties in the optional `namedConfigs.namedCustomOrders` parameter. |\n| [namedConfigs] | <code>object</code> | Provides a means of reusing computed property functions and custom sort types. |\n| [namedConfigs.namedComputedProps] | <code>object</code> | Key/value pairs, where the keys correspond to strings given in the sortBy property list, and the values are functions which will dynamically calculated values for each property in the input array. |\n| [namedConfigs.namedCustomOrders] | <code>object</code> | Key/value pairs, where the keys correspond to strings given in the sortTypes list, and the values are arrays of custom values which define the sort type. |\n\n**Example**  \nwith this data\n```js\n> DJs = [\n  { name: 'Trevor', slot: 'twilight' },\n  { name: 'Chris', slot: 'twilight' },\n  { name: 'Mike', slot: 'afternoon' },\n  { name: 'Rodney', slot: 'morning' },\n  { name: 'Chris', slot: 'morning' },\n  { name: 'Zane', slot: 'evening' }\n]\n```\n\nsort by `slot` using an ascending sort type\n```js\n> sortBy(DJs, [ 'slot' ], [ 'asc' ])\n[ { name: 'Mike', slot: 'afternoon' },\n  { name: 'Zane', slot: 'evening' },\n  { name: 'Chris', slot: 'morning' },\n  { name: 'Rodney', slot: 'morning' },\n  { name: 'Chris', slot: 'twilight' },\n  { name: 'Trevor', slot: 'twilight' } ]\n```\n\nsort by `slot` using a descending sort type\n```js\n> sortBy(DJs, [ 'slot' ], [ 'desc' ])\n[ { name: 'Chris', slot: 'twilight' },\n  { name: 'Trevor', slot: 'twilight' },\n  { name: 'Chris', slot: 'morning' },\n  { name: 'Rodney', slot: 'morning' },\n  { name: 'Zane', slot: 'evening' },\n  { name: 'Mike', slot: 'afternoon' }]\n```\n\nsort by `slot` using an 'inline' custom sort type\n```js\n> sortBy(DJs, [ 'slot' ], [ 'morning', 'afternoon', 'evening', 'twilight' ])\n[ { name: 'Rodney', slot: 'morning' },\n  { name: 'Chris', slot: 'morning' },\n  { name: 'Mike', slot: 'afternoon' },\n  { name: 'Zane', slot: 'evening' },\n  { name: 'Trevor', slot: 'twilight' },\n  { name: 'Chris', slot: 'twilight' } ]\n```\n\nsort by `slot` using an 'named' custom sort type\n```js\n> let namedConfigs = {\n    namedCustomOrders: {\n      custOrder1: [ 'morning', 'afternoon', 'evening', 'twilight' ]\n    }\n  }\n> sortBy(DJs, [ 'slot' ], [ 'custOrder1' ], namedConfigs)\n[ { name: 'Rodney', slot: 'morning' },\n  { name: 'Chris', slot: 'morning' },\n  { name: 'Mike', slot: 'afternoon' },\n  { name: 'Zane', slot: 'evening' },\n  { name: 'Trevor', slot: 'twilight' },\n  { name: 'Chris', slot: 'twilight' } ]\n```\n\nsort by `slot` (with a custom sort type) then `name` (with an ascending sort type)\n```js\n> sortBy(DJs, ['slot', 'name'], [ [ 'morning', 'afternoon', 'evening', 'twilight' ], 'asc' ])\n[ { name: 'Chris', slot: 'morning' },\n  { name: 'Rodney', slot: 'morning' },\n  { name: 'Mike', slot: 'afternoon' },\n  { name: 'Zane', slot: 'evening' },\n  { name: 'Chris', slot: 'twilight' },\n  { name: 'Trevor', slot: 'twilight' } ]\n```\n\n* * *\n\n&copy; 2015-19 Lloyd Brookes \\<75pound@gmail.com\\>. Documented by [jsdoc-to-markdown](https://github.com/jsdoc2md/jsdoc-to-markdown).\n","readmeFilename":"README.md","gitHead":"e15b9408c727e0b0aa4e67d9f47f9e631822e788","bugs":{"url":"https://github.com/75lb/sort-array/issues"},"homepage":"https://github.com/75lb/sort-array#readme","_id":"sort-array@3.0.0-1","_nodeVersion":"12.10.0","_npmVersion":"6.11.3","dist":{"integrity":"sha512-qryKCklFqSTNS8mkhckOuAyeD+/4iJZC+/p7zSaTK/kCYo32hnKLTLP0TTRRZrbwbAisfLpYe806WSKHcYiadw==","shasum":"a05e0afac4ead775f659ae81a7140d5474619a82","tarball":"http://registry-npm.ywwl.com/sort-array/download/sort-array-3.0.0-1.tgz","fileCount":6,"unpackedSize":30298,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdi8rCCRA9TVsSAnZWagAAhocP/jJt0/UNEHrTplYuiVMp\nEpKMasr58VBRjM5Ed7pU3Q4GCKtTnt9amdH/IglxVmsaujVf7n7oGPU5w0zg\nUS4ewyBz6vKmLskXHDoz8V2/kiHZOAfvDsscgSJx46G8QwZs6ZiYF72QkeOX\nkX+lQB7Wx4xxr+9da/apUgIKyIYpHxNJFGdc33yAlYB/HslENaFVz0zh/w9t\nd8mXXlh/+qLzXIIIOEoJ07E1vYIMFM8ZA/gt1f/GTmck9ONgmp1tJs2r8pEV\n0rzMfAalMrBYipsSHIZ8KrSqhAA2+eQSfA9Xe7rmmUkUQFjaNgwct/PlDM53\nW2zMcZMK4PUNYjQM0ZEOAxFGsGKyfkwSWOr0PRJGqS+ByqiEbYXMLPWjuXJX\nYXdgz3SMZRcfwh2f1SdZXIC233oPEFYGJ6WYwgAHrNwZjO3fFfpM2pDLJnr/\n1lABArtL6+lCEPgfiBjACH7hO5dkG7o85RZ+4a8liu2zgKbTFZxOyGpfh/sg\n1jopCG9DrDHdzSLoOECy5xFER7/uKFgWHaShmw8Cl+1Xon/texUG5XmoRa3a\noUGG0HbZYSomP5chP5Zz33J80YnFigyxm5Ccc1zh/vMIUdy0m3kifV82t7fF\n0qVOoa7TnxkGr73I8h91ZQrZEjuSHNMe/TBGSIbzBF+Kv877znmeKFU0Mv9F\njz1F\r\n=VO+n\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIDERJZ6mBlSkwm8n2c1FC507XmYzxaOoCECQK+RjY8CEAiBKPa16XL8l8BzNEUcUrUWJdw2GpT97a+V1oUn/jWPNqA=="}],"size":5850,"noattachment":false,"key":"/sort-array/-/sort-array-3.0.0-1.tgz"},"maintainers":[{"name":"75lb","email":"75pound@gmail.com"}],"_npmUser":{"name":"75lb","email":"75pound@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/sort-array_3.0.0-1_1569442497671_0.2607712815072387"},"_hasShrinkwrap":false,"publish_time":1569442497767,"_cnpm_publish_time":1569442497767,"dist-tags":{"latest":"5.1.2","next":"4.1.0-0"}}