{"name":"compare-func","version":"1.0.1","description":"Get a compare function for array to sort","homepage":"https://github.com/stevemao/compare-func","author":{"name":"Steve Mao","email":"maochenyan@gmail.com","url":"https://github.com/stevemao"},"repository":{"type":"git","url":"https://github.com/stevemao/compare-func"},"license":"MIT","files":["index.js"],"keywords":["compare-func","arr","array","by","compare","dot","get","obj","object","prop","property","sort","sorting"],"dependencies":{"dot-prop":"^1.0.1","lodash.clonedeep":"^3.0.0","lodash.foreach":"^3.0.2"},"devDependencies":{"coveralls":"^2.11.2","istanbul":"^0.3.8","jscs":"^1.11.3","jshint":"^2.6.3","mocha":"*"},"scripts":{"coverage":"istanbul cover _mocha -- -R spec && rm -rf ./coverage","lint":"jshint *.js --exclude node_modules && jscs *.js","test":"npm run-script lint && mocha"},"gitHead":"cd7e6d55284b98138cbb33455709dbe4c1548b6e","bugs":{"url":"https://github.com/stevemao/compare-func/issues"},"_id":"compare-func@1.0.1","_shasum":"a16acd0857f0afa395e653ed6f77f51a6028a824","_from":".","_npmVersion":"2.7.5","_nodeVersion":"0.12.0","_npmUser":{"name":"stevemao","email":"steve.mao@healthinteract.com.au"},"maintainers":[{"name":"stevemao","email":"steve.mao@healthinteract.com.au"}],"dist":{"shasum":"a16acd0857f0afa395e653ed6f77f51a6028a824","tarball":"http://registry-npm.ywwl.com/compare-func/download/compare-func-1.0.1.tgz","integrity":"sha512-xa0h6EPZJjT8+1st7GTThcU7a0YRq45LF/aCpP/OvjQ2QeK6SmneDJgrpnwaZKQ0uYEsT8qgjzjSHqD0TMcz8w==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIG/CWEyNUsTlrBiDwy8dWjNXHSNwBfhnt+w05AmjR9bOAiEAwRthE0glKyKL6uVrLZ/aJkLSHtURLngigrKOOFRRANg="}],"size":1538,"noattachment":false,"key":"/compare-func/-/compare-func-1.0.1.tgz"},"directories":{},"readme":"#  [![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Dependency Status][daviddm-image]][daviddm-url] [![Coverage Status][coveralls-image]][coveralls-url]\n\n> Get a compare function for array to sort\n\n\n## Install\n\n```sh\n$ npm install --save compare-func\n```\n\n\n## Usage\n\n```js\nvar compareFunc = require('compare-func');\n\n// sort by an object property\n[{x: 'b'}, {x: 'a'}, {x: 'c'}].sort(compareFunc('x'));\n//=> [{x: 'a'}, {x: 'b'}, {x: 'c'}]\n\n// sort by a nested object property\n[{x: {y: 'b'}}, {x: {y: 'a'}}].sort(compareFunc('x.y'));\n//=> [{x: {y: 'a'}}, {x: {y: 'b'}}]\n\n// sort by the `x` propery, then `y`\n[{x: 'c', y: 'c'}, {x: 'b', y: 'a'}, {x: 'b', y: 'b'}].sort(compareFunc(['x', 'y']));\n//=> [{x: 'b', y: 'a'}, {x: 'b', y: 'b'}, {x: 'c', y: 'c'}]\n\n// sort by the returned value\n[{x: 'b'}, {x: 'a'}, {x: 'c'}].sort(compareFunc(function(el) {\n  return el.x;\n}));\n//=> [{x: 'a'}, {x: 'b'}, {x: 'c'}]\n```\n\n\n## API\n\n### compareFunc([property])\n\nReturns a compare function for array to sort\n\n#### property\n\nType: `string`, `function` or `array` of either\n\nIf missing it sorts on itself.\n\nThe string can be a [dot path](https://github.com/sindresorhus/dot-prop) to a nested object property.\n\n\n## Related\n\n- [sort-on](https://github.com/sindresorhus/sort-on) - Sort an array on an object property\n\n\n## License\n\nMIT © [Steve Mao](https://github.com/stevemao)\n\n\n[npm-image]: https://badge.fury.io/js/compare-func.svg\n[npm-url]: https://npmjs.org/package/compare-func\n[travis-image]: https://travis-ci.org/stevemao/compare-func.svg?branch=master\n[travis-url]: https://travis-ci.org/stevemao/compare-func\n[daviddm-image]: https://david-dm.org/stevemao/compare-func.svg?theme=shields.io\n[daviddm-url]: https://david-dm.org/stevemao/compare-func\n[coveralls-image]: https://coveralls.io/repos/stevemao/compare-func/badge.svg\n[coveralls-url]: https://coveralls.io/r/stevemao/compare-func\n","publish_time":1428066857080,"_cnpm_publish_time":1428066857080,"dist-tags":{"latest":"2.0.0"}}