{"name":"compare-func","version":"1.3.2","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":"git+https://github.com/stevemao/compare-func.git"},"license":"MIT","files":["index.js"],"keywords":["compare-func","arr","array","by","compare","dot","get","obj","object","prop","property","sort","sorting"],"dependencies":{"array-ify":"^1.0.0","dot-prop":"^3.0.0"},"devDependencies":{"coveralls":"^2.11.2","istanbul":"^0.4.4","jscs":"^3.0.5","jshint":"^2.7.0","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":"8b3d32bc2540aae38a000205ea3345a77e0e1b50","bugs":{"url":"https://github.com/stevemao/compare-func/issues"},"_id":"compare-func@1.3.2","_shasum":"99dd0ba457e1f9bc722b12c08ec33eeab31fa648","_from":".","_npmVersion":"2.15.1","_nodeVersion":"4.4.4","_npmUser":{"name":"stevemao","email":"maochenyan@gmail.com"},"dist":{"shasum":"99dd0ba457e1f9bc722b12c08ec33eeab31fa648","tarball":"http://registry-npm.ywwl.com/compare-func/download/compare-func-1.3.2.tgz","integrity":"sha512-k6Qzw6O4v6q/F0vL+rn95LwQoWtqJv6+dtbVPw/jC0zKGphAdq++3Q1ZVm25XbqOQ7kFXlBbJoycmsaFPDop3Q==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCID9SAXs4X4lbZr1Pm4FaUx73PVKnIasSkuAoydwtyyv1AiBi4y6KmvFwLumfM1DdDHjxQ1l/PueO1bpxBWmCIXBFLA=="}],"size":1510,"noattachment":false,"key":"/compare-func/-/compare-func-1.3.2.tgz"},"maintainers":[{"name":"stevemao","email":"steve.mao@healthinteract.com.au"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/compare-func-1.3.2.tgz_1467271872418_0.13966840622015297"},"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":1467271872949,"_cnpm_publish_time":1467271872949,"dist-tags":{"latest":"2.0.0"}}