{"_id":"array-sort","_rev":"74226","name":"array-sort","description":"Fast and powerful array sorting. Sort an array of objects by one or more properties. Any number of nested properties or custom comparison functions may be used.","dist-tags":{"latest":"1.0.0"},"maintainers":[{"name":"doowb","email":"brian.woodward@gmail.com"},{"name":"jonschlinkert","email":"github@sellside.com"}],"time":{"modified":"2021-06-03T10:24:11.000Z","created":"2015-07-18T06:32:29.758Z","1.0.0":"2017-12-06T19:45:43.652Z","0.1.4":"2017-09-11T18:20:00.810Z","0.1.3":"2017-07-24T05:37:48.346Z","0.1.2":"2016-04-21T06:06:31.100Z","0.1.1":"2015-07-18T14:25:45.043Z","0.1.0":"2015-07-18T06:32:29.758Z"},"users":{"rocket0191":true},"author":{"name":"Jon Schlinkert","url":"https://github.com/jonschlinkert"},"repository":{"type":"git","url":"git+https://github.com/jonschlinkert/array-sort.git"},"versions":{"1.0.0":{"name":"array-sort","description":"Fast and powerful array sorting. Sort an array of objects by one or more properties. Any number of nested properties or custom comparison functions may be used.","version":"1.0.0","homepage":"https://github.com/jonschlinkert/array-sort","author":{"name":"Jon Schlinkert","url":"https://github.com/jonschlinkert"},"contributors":[{"name":"Brian Woodward","url":"https://twitter.com/doowb"},{"name":"Jan Stola","url":"https://github.com/iamstolis"},{"name":"Jon Schlinkert","url":"http://twitter.com/jonschlinkert"},{"name":"Kevin Ward","url":"https://github.com/wkevina"}],"repository":{"type":"git","url":"git+https://github.com/jonschlinkert/array-sort.git"},"bugs":{"url":"https://github.com/jonschlinkert/array-sort/issues"},"license":"MIT","files":["index.js"],"main":"index.js","engines":{"node":">=0.10.0"},"scripts":{"test":"mocha"},"dependencies":{"default-compare":"^1.0.0","get-value":"^2.0.6","kind-of":"^5.0.2"},"devDependencies":{"ansi-bold":"^0.1.1","benchmarked":"^0.1.5","glob":"^7.0.3","gulp-format-md":"^0.1.8","lodash.sortbyorder":"^3.4.4","mocha":"^2.4.5","should":"^8.3.1"},"keywords":["arr","array","asc","ascend","ascending","desc","descend","descending","dot","element","elements","get","multiple","nested","obj","object","order","ordered","path","prop","properties","property","sort","sorted","sorting"],"verb":{"reflinks":["verb"],"related":{"list":["get-value","set-value","sort-asc","sort-desc","sort-object"]},"toc":false,"layout":"default","tasks":["readme"],"plugins":["gulp-format-md"],"lint":{"reflinks":true}},"gitHead":"a7913f8ec9b3891a01eaf71636a7acc7e638f9a0","_id":"array-sort@1.0.0","_npmVersion":"5.3.0","_nodeVersion":"8.4.0","_npmUser":{"name":"doowb","email":"brian.woodward@gmail.com"},"dist":{"shasum":"e4c05356453f56f53512a7d1d6123f2c54c0a88a","size":4336,"noattachment":false,"key":"/array-sort/-/array-sort-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/array-sort/download/array-sort-1.0.0.tgz"},"maintainers":[{"name":"doowb","email":"brian.woodward@gmail.com"},{"name":"jonschlinkert","email":"github@sellside.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/array-sort-1.0.0.tgz_1512589543584_0.027421483770012856"},"directories":{},"publish_time":1512589543652,"_hasShrinkwrap":false,"_cnpm_publish_time":1512589543652},"0.1.4":{"name":"array-sort","description":"Fast and powerful array sorting. Sort an array of objects by one or more properties. Any number of nested properties or custom comparison functions may be used.","version":"0.1.4","homepage":"https://github.com/jonschlinkert/array-sort","author":{"name":"Jon Schlinkert","url":"https://github.com/jonschlinkert"},"contributors":[{"name":"Jon Schlinkert","url":"http://twitter.com/jonschlinkert"},{"name":"Kevin Ward","url":"https://github.com/wkevina"}],"repository":{"type":"git","url":"git+https://github.com/jonschlinkert/array-sort.git"},"bugs":{"url":"https://github.com/jonschlinkert/array-sort/issues"},"license":"MIT","files":["index.js"],"main":"index.js","engines":{"node":">=0.10.0"},"scripts":{"test":"mocha"},"dependencies":{"default-compare":"^1.0.0","get-value":"^2.0.6","kind-of":"^5.0.2"},"devDependencies":{"ansi-bold":"^0.1.1","benchmarked":"^0.1.5","glob":"^7.0.3","gulp-format-md":"^0.1.8","lodash.sortbyorder":"^3.4.4","mocha":"^2.4.5","should":"^8.3.1"},"keywords":["arr","array","asc","ascend","ascending","desc","descend","descending","dot","element","elements","get","multiple","nested","obj","object","order","ordered","path","prop","properties","property","sort","sorted","sorting"],"verb":{"reflinks":["verb"],"related":{"list":["get-value","set-value","sort-asc","sort-desc","sort-object"]},"toc":false,"layout":"default","tasks":["readme"],"plugins":["gulp-format-md"],"lint":{"reflinks":true}},"gitHead":"ee89f397445cbbbc6f2678cbaded398b075f2f79","_id":"array-sort@0.1.4","_npmVersion":"5.3.0","_nodeVersion":"8.4.0","_npmUser":{"name":"doowb","email":"brian.woodward@gmail.com"},"dist":{"shasum":"662855eaeb671b4188df4451b2f24a0753992b23","size":4300,"noattachment":false,"key":"/array-sort/-/array-sort-0.1.4.tgz","tarball":"http://registry.cnpm.dingdandao.com/array-sort/download/array-sort-0.1.4.tgz"},"maintainers":[{"name":"doowb","email":"brian.woodward@gmail.com"},{"name":"jonschlinkert","email":"github@sellside.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/array-sort-0.1.4.tgz_1505154000663_0.9003231637179852"},"directories":{},"publish_time":1505154000810,"_hasShrinkwrap":false,"_cnpm_publish_time":1505154000810},"0.1.3":{"name":"array-sort","description":"Fast and powerful array sorting. Sort an array of objects by one or more properties. Any number of nested properties or custom comparison functions may be used.","version":"0.1.3","homepage":"https://github.com/jonschlinkert/array-sort","author":{"name":"Jon Schlinkert","url":"https://github.com/jonschlinkert"},"contributors":[{"name":"Jon Schlinkert","url":"http://twitter.com/jonschlinkert"},{"name":"Kevin Ward","url":"https://github.com/wkevina"}],"repository":{"type":"git","url":"git+https://github.com/jonschlinkert/array-sort.git"},"bugs":{"url":"https://github.com/jonschlinkert/array-sort/issues"},"license":"MIT","files":["index.js"],"main":"index.js","engines":{"node":">=0.10.0"},"scripts":{"test":"mocha"},"dependencies":{"get-value":"^2.0.5","kind-of":"^2.0.0"},"devDependencies":{"ansi-bold":"^0.1.1","benchmarked":"^0.1.5","glob":"^7.0.3","gulp-format-md":"^0.1.8","lodash.sortbyorder":"^3.4.4","mocha":"^2.4.5","should":"^8.3.1"},"keywords":["arr","array","asc","ascend","ascending","desc","descend","descending","dot","element","elements","get","multiple","nested","obj","object","order","ordered","path","prop","properties","property","sort","sorted","sorting"],"verb":{"reflinks":["verb"],"related":{"list":["get-value","set-value","sort-asc","sort-desc","sort-object"]},"toc":false,"layout":"default","tasks":["readme"],"plugins":["gulp-format-md"],"lint":{"reflinks":true}},"gitHead":"c8024b8d8e9c6b193e388798f8ad1e535f087235","_id":"array-sort@0.1.3","_shasum":"421cdad9c975c4ccbd8b6499333bf2c6d1ed627b","_from":".","_npmVersion":"4.6.1","_nodeVersion":"6.10.1","_npmUser":{"name":"doowb","email":"brian.woodward@gmail.com"},"dist":{"shasum":"421cdad9c975c4ccbd8b6499333bf2c6d1ed627b","size":4301,"noattachment":false,"key":"/array-sort/-/array-sort-0.1.3.tgz","tarball":"http://registry.cnpm.dingdandao.com/array-sort/download/array-sort-0.1.3.tgz"},"maintainers":[{"name":"doowb","email":"brian.woodward@gmail.com"},{"name":"jonschlinkert","email":"github@sellside.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/array-sort-0.1.3.tgz_1500874668247_0.5818684871774167"},"directories":{},"publish_time":1500874668346,"_hasShrinkwrap":false,"_cnpm_publish_time":1500874668346},"0.1.2":{"name":"array-sort","description":"Fast and powerful array sorting. Sort an array of objects by one or more properties. Any number of nested properties or custom comparison functions may be used.","version":"0.1.2","homepage":"https://github.com/jonschlinkert/array-sort","author":{"name":"Jon Schlinkert","url":"https://github.com/jonschlinkert"},"repository":{"type":"git","url":"git+https://github.com/jonschlinkert/array-sort.git"},"bugs":{"url":"https://github.com/jonschlinkert/array-sort/issues"},"license":"MIT","files":["index.js"],"main":"index.js","engines":{"node":">=0.10.0"},"scripts":{"test":"mocha"},"dependencies":{"get-value":"^2.0.5","kind-of":"^2.0.0"},"devDependencies":{"ansi-bold":"^0.1.1","benchmarked":"^0.1.5","glob":"^7.0.3","gulp-format-md":"^0.1.8","lodash.sortbyorder":"^3.4.4","mocha":"^2.4.5","should":"^8.3.1"},"keywords":["arr","array","asc","ascend","ascending","desc","descend","descending","dot","element","elements","get","multiple","nested","obj","object","order","ordered","path","prop","properties","property","sort","sorted","sorting"],"verb":{"reflinks":["verb"],"related":{"list":["get-value","set-value","sort-asc","sort-desc","sort-object"]},"toc":false,"layout":"default","tasks":["readme"],"plugins":["gulp-format-md"],"lint":{"reflinks":true}},"gitHead":"2db2ea294d044df400085c080da3088f700af74d","_id":"array-sort@0.1.2","_shasum":"aea6fc9253f33fae7e8c35b02004b381ad0d6433","_from":".","_npmVersion":"3.6.0","_nodeVersion":"5.5.0","_npmUser":{"name":"jonschlinkert","email":"github@sellside.com"},"maintainers":[{"name":"doowb","email":"brian.woodward@gmail.com"},{"name":"jonschlinkert","email":"github@sellside.com"}],"dist":{"shasum":"aea6fc9253f33fae7e8c35b02004b381ad0d6433","size":3991,"noattachment":false,"key":"/array-sort/-/array-sort-0.1.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/array-sort/download/array-sort-0.1.2.tgz"},"_npmOperationalInternal":{"host":"packages-16-east.internal.npmjs.com","tmp":"tmp/array-sort-0.1.2.tgz_1461218789772_0.61351925926283"},"directories":{},"publish_time":1461218791100,"_cnpm_publish_time":1461218791100,"_hasShrinkwrap":false},"0.1.1":{"name":"array-sort","description":"Fast and powerful array sorting. Sort an array of objects by one or more properties. Any number of nested properties or custom comparison functions may be used.","version":"0.1.1","homepage":"https://github.com/jonschlinkert/array-sort","author":{"name":"Jon Schlinkert","url":"https://github.com/jonschlinkert"},"repository":{"type":"git","url":"git+https://github.com/jonschlinkert/array-sort.git"},"bugs":{"url":"https://github.com/jonschlinkert/array-sort/issues"},"license":"MIT","files":["index.js"],"main":"index.js","engines":{"node":">=0.10.0"},"scripts":{"test":"mocha"},"dependencies":{"get-value":"^1.1.5","kind-of":"^2.0.0"},"devDependencies":{"ansi-bold":"^0.1.1","benchmarked":"^0.1.4","glob":"^5.0.14","lodash.sortbyorder":"^3.4.4","mocha":"*","should":"*"},"keywords":["arr","array","asc","ascend","ascending","desc","descend","descending","dot","element","elements","get","multiple","nested","obj","object","order","ordered","path","prop","properties","property","sort","sorted","sorting"],"verb":{"related":{"list":["sort-asc","sort-desc","get-value","set-value","sort-object"]}},"gitHead":"616e8967c7e3c340c66cd4a75ed8f25c3793b960","_id":"array-sort@0.1.1","_shasum":"f1d561dc35783413e9cf4b982e1afb025308cee0","_from":".","_npmVersion":"2.10.1","_nodeVersion":"0.12.4","_npmUser":{"name":"jonschlinkert","email":"github@sellside.com"},"maintainers":[{"name":"doowb","email":"brian.woodward@gmail.com"},{"name":"jonschlinkert","email":"github@sellside.com"}],"dist":{"shasum":"f1d561dc35783413e9cf4b982e1afb025308cee0","size":3787,"noattachment":false,"key":"/array-sort/-/array-sort-0.1.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/array-sort/download/array-sort-0.1.1.tgz"},"directories":{},"publish_time":1437229545043,"_cnpm_publish_time":1437229545043,"_hasShrinkwrap":false},"0.1.0":{"name":"array-sort","description":"Fast and powerful array sorting. Sort an array of objects by one or more properties. Any number of nested properties or custom comparison functions may be used.","version":"0.1.0","homepage":"https://github.com/jonschlinkert/array-sort","author":{"name":"Jon Schlinkert","url":"https://github.com/jonschlinkert"},"repository":{"type":"git","url":"git+https://github.com/jonschlinkert/array-sort.git"},"bugs":{"url":"https://github.com/jonschlinkert/array-sort/issues"},"license":"MIT","files":["index.js"],"main":"index.js","engines":{"node":">=0.10.0"},"scripts":{"test":"mocha"},"dependencies":{"get-value":"^1.1.5","kind-of":"^2.0.0"},"devDependencies":{"mocha":"*","should":"*"},"keywords":["arr","array","asc","ascend","ascending","desc","descend","descending","dot","element","elements","get","multiple","nested","obj","object","order","ordered","path","prop","properties","property","sort","sorted","sorting"],"verb":{"related":{"list":["sort-asc","sort-desc","get-value","set-value","sort-object"]}},"gitHead":"8d160bb7ab415f3b0868e795f3bd4cb1596802fa","_id":"array-sort@0.1.0","_shasum":"b71ff5542d6abe4eb1ec03149d3db30aacccd9b8","_from":".","_npmVersion":"2.10.1","_nodeVersion":"0.12.4","_npmUser":{"name":"jonschlinkert","email":"github@sellside.com"},"maintainers":[{"name":"doowb","email":"brian.woodward@gmail.com"},{"name":"jonschlinkert","email":"github@sellside.com"}],"dist":{"shasum":"b71ff5542d6abe4eb1ec03149d3db30aacccd9b8","size":4031,"noattachment":false,"key":"/array-sort/-/array-sort-0.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/array-sort/download/array-sort-0.1.0.tgz"},"directories":{},"publish_time":1437201149758,"_cnpm_publish_time":1437201149758,"_hasShrinkwrap":false}},"readme":"# array-sort [![NPM version](https://img.shields.io/npm/v/array-sort.svg?style=flat)](https://www.npmjs.com/package/array-sort) [![NPM monthly downloads](https://img.shields.io/npm/dm/array-sort.svg?style=flat)](https://npmjs.org/package/array-sort)  [![NPM total downloads](https://img.shields.io/npm/dt/array-sort.svg?style=flat)](https://npmjs.org/package/array-sort) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/array-sort.svg?style=flat&label=Travis)](https://travis-ci.org/jonschlinkert/array-sort) [![Windows Build Status](https://img.shields.io/appveyor/ci/jonschlinkert/array-sort.svg?style=flat&label=AppVeyor)](https://ci.appveyor.com/project/jonschlinkert/array-sort)\n\n> Fast and powerful array sorting. Sort an array of objects by one or more properties. Any number of nested properties or custom comparison functions may be used.\n\n## Install\n\nInstall with [npm](https://www.npmjs.com/):\n\n```sh\n$ npm install --save array-sort\n```\n\nInstall with [yarn](https://yarnpkg.com):\n\n```sh\n$ yarn add array-sort\n```\n\n## Usage\n\nSort an array by the given object property:\n\n```js\nvar arraySort = require('array-sort');\n\narraySort([{foo: 'y'}, {foo: 'z'}, {foo: 'x'}], 'foo');\n//=> [{foo: 'x'}, {foo: 'y'}, {foo: 'z'}]\n```\n\n**Reverse order**\n\n```js\narraySort([{foo: 'y'}, {foo: 'z'}, {foo: 'x'}], 'foo', {reverse: true});\n//=> [{foo: 'z'}, {foo: 'y'}, {foo: 'x'}]\n```\n\n## Params\n\n```js\narraySort(array, comparisonArgs);\n```\n\n* `array`: **{Array}** The array to sort\n* `comparisonArgs`: **{Function|String|Array}**: One or more functions or object paths to use for sorting.\n\n## Examples\n\n**[Sort blog posts](examples/blog-posts.js)**\n\n```js\nvar arraySort = require('array-sort');\n\nvar posts = [\n  { path: 'c.md', locals: { date: '2014-01-09' } },\n  { path: 'a.md', locals: { date: '2014-01-02' } },\n  { path: 'b.md', locals: { date: '2013-05-06' } },\n];\n\n// sort by `locals.date`\nconsole.log(arraySort(posts, 'locals.date'));\n\n// sort by `path`\nconsole.log(arraySort(posts, 'path'));\n```\n\n**[Sort by multiple properties](examples/multiple-props.js)**\n\n```js\nvar arraySort = require('array-sort');\n\nvar posts = [\n  { locals: { foo: 'bbb', date: '2013-05-06' }},\n  { locals: { foo: 'aaa', date: '2012-01-02' }},\n  { locals: { foo: 'ccc', date: '2014-01-02' }},\n  { locals: { foo: 'ccc', date: '2015-01-02' }},\n  { locals: { foo: 'bbb', date: '2014-06-01' }},\n  { locals: { foo: 'aaa', date: '2014-02-02' }},\n];\n\n// sort by `locals.foo`, then `locals.date`\nvar result = arraySort(posts, ['locals.foo', 'locals.date']);\n\nconsole.log(result);\n// [ { locals: { foo: 'aaa', date: '2012-01-02' } },\n//   { locals: { foo: 'aaa', date: '2014-02-02' } },\n//   { locals: { foo: 'bbb', date: '2013-05-06' } },\n//   { locals: { foo: 'bbb', date: '2014-06-01' } },\n//   { locals: { foo: 'ccc', date: '2014-01-02' } },\n//   { locals: { foo: 'ccc', date: '2015-01-02' } } ]\n```\n\n**[Custom function](examples/custom-function.js)**\n\nIf custom functions are supplied, array elements are sorted according to the return value of the compare function. See the [docs for ](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort)`Array.sort()` for more details.\n\n```js\nvar arr = [\n  {one: 'w', two: 'b'},\n  {one: 'z', two: 'a'},\n  {one: 'x', two: 'c'},\n  {one: 'y', two: 'd'},\n];\n\nfunction compare(prop) {\n  return function (a, b) {\n    return a[prop].localeCompare(b[prop]);\n  };\n}\n\nvar result = arraySort(arr, function (a, b) {\n  return a.two.localeCompare(b.two);\n});\n\nconsole.log(result);\n// [ { one: 'z', two: 'a' },\n//   { one: 'w', two: 'b' },\n//   { one: 'x', two: 'c' },\n//   { one: 'y', two: 'd' } ]\n```\n\n**[Multiple custom functions](examples/custom-functions.js)**\n\n```js\nvar arr = [\n  {foo: 'w', bar: 'y', baz: 'w'},\n  {foo: 'x', bar: 'y', baz: 'w'},\n  {foo: 'x', bar: 'y', baz: 'z'},\n  {foo: 'x', bar: 'x', baz: 'w'},\n];\n\n// reusable compare function\nfunction compare(prop) {\n  return function (a, b) {\n    return a[prop].localeCompare(b[prop]);\n  };\n}\n\n// the `compare` functions can be a list or array\nvar result = arraySort(arr, compare('foo'), compare('bar'), compare('baz'));\n\nconsole.log(result);\n// [ { foo: 'w', bar: 'y', baz: 'w' },\n//   { foo: 'x', bar: 'x', baz: 'w' },\n//   { foo: 'x', bar: 'y', baz: 'w' },\n//   { foo: 'x', bar: 'y', baz: 'z' } ]\n```\n\n## About\n\n### Related projects\n\n* [get-value](https://www.npmjs.com/package/get-value): Use property paths (`a.b.c`) to get a nested value from an object. | [homepage](https://github.com/jonschlinkert/get-value \"Use property paths (`a.b.c`) to get a nested value from an object.\")\n* [set-value](https://www.npmjs.com/package/set-value): Create nested values and any intermediaries using dot notation (`'a.b.c'`) paths. | [homepage](https://github.com/jonschlinkert/set-value \"Create nested values and any intermediaries using dot notation (`'a.b.c'`) paths.\")\n* [sort-asc](https://www.npmjs.com/package/sort-asc): Sort array elements in ascending order. | [homepage](https://github.com/jonschlinkert/sort-asc \"Sort array elements in ascending order.\")\n* [sort-desc](https://www.npmjs.com/package/sort-desc): Sort array elements in descending order. | [homepage](https://github.com/jonschlinkert/sort-desc \"Sort array elements in descending order.\")\n* [sort-object](https://www.npmjs.com/package/sort-object): Sort the keys in an object. | [homepage](https://github.com/doowb/sort-object \"Sort the keys in an object.\")\n\n### Contributing\n\nPull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).\n\n### Contributors\n\n| **Commits** | **Contributor** |  \n| --- | --- |  \n| 10 | [jonschlinkert](https://github.com/jonschlinkert) |  \n| 4  | [doowb](https://github.com/doowb) |  \n| 1  | [iamstolis](https://github.com/iamstolis) |  \n| 1  | [wkevina](https://github.com/wkevina) |  \n\n### Building docs\n\n_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_\n\nTo generate the readme, run the following command:\n\n```sh\n$ npm install -g verbose/verb#dev verb-generate-readme && verb\n```\n\n### Running tests\n\nRunning and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:\n\n```sh\n$ npm install && npm test\n```\n\n### Author\n\n**Jon Schlinkert**\n\n* [github/jonschlinkert](https://github.com/jonschlinkert)\n* [twitter/jonschlinkert](https://twitter.com/jonschlinkert)\n\n### License\n\nCopyright © 2017, [Jon Schlinkert](https://github.com/jonschlinkert).\nReleased under the [MIT License](LICENSE).\n\n***\n\n_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on September 11, 2017._","_attachments":{},"homepage":"https://github.com/jonschlinkert/array-sort","bugs":{"url":"https://github.com/jonschlinkert/array-sort/issues"},"license":"MIT"}