{"name":"compare-func","version":"1.2.0","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":{"clone":"^1.0.2","dot-prop":"^2.0.0"},"devDependencies":{"coveralls":"^2.11.2","istanbul":"^0.3.13","jscs":"^1.13.1","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":"a0aa0985a95383745b6a1b48f375625ece0d7479","bugs":{"url":"https://github.com/stevemao/compare-func/issues"},"_id":"compare-func@1.2.0","_shasum":"5df100650f315ad3c8d314603ecd7cf8261174fc","_from":".","_npmVersion":"2.8.3","_nodeVersion":"0.12.2","_npmUser":{"name":"stevemao","email":"steve.mao@healthinteract.com.au"},"maintainers":[{"name":"stevemao","email":"steve.mao@healthinteract.com.au"}],"dist":{"shasum":"5df100650f315ad3c8d314603ecd7cf8261174fc","tarball":"http://registry-npm.ywwl.com/compare-func/download/compare-func-1.2.0.tgz","integrity":"sha512-R4wJbjd1owU6Os+eeHvwelR0kPpVDTi4SsMF8WI3K7WaUqesAYIm4R+/OshA/Q9CL5MBTNixKI2MKbXB6jfKQQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIDkh1pMJqR0grGIQ+y4bGVYCaJYruNKljewYQozi2AHQAiBFZedldih46MSRS3VhsRKl6qs4omWz7KOIgCTM+0AskQ=="}],"size":1531,"noattachment":false,"key":"/compare-func/-/compare-func-1.2.0.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":1430723733336,"_cnpm_publish_time":1430723733336,"dist-tags":{"latest":"2.0.0"}}