{"name":"compare-func","version":"2.0.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","keywords":["compare-func","arr","array","by","compare","dot","get","obj","object","prop","property","sort","sorting"],"dependencies":{"array-ify":"^1.0.0","dot-prop":"^5.1.0"},"devDependencies":{"coveralls":"^2.11.2","istanbul":"^0.4.4","jscs":"^3.0.5","jshint":"^2.7.0","mocha":"^7.1.2"},"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":"ea273199551fcb4fdfd6c34a37cb263e5117825d","bugs":{"url":"https://github.com/stevemao/compare-func/issues"},"_id":"compare-func@2.0.0","_nodeVersion":"12.16.1","_npmVersion":"6.13.4","dist":{"integrity":"sha512-zHig5N+tPWARooBnb0Zx1MFcdfpyJrfTJ3Y5L+IFvUm8rM74hHz66z0gw0x4tijh5CorKkKUCnW82R2vmpeCRA==","shasum":"fb65e75edbddfd2e568554e8b5b05fff7a51fcb3","tarball":"http://registry-npm.ywwl.com/compare-func/download/compare-func-2.0.0.tgz","fileCount":4,"unpackedSize":4762,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJevpqaCRA9TVsSAnZWagAAb8wP/jwGzWwq9bysqIY+gQb0\n9GJ4IGoZAHSx2yEAPqEODjcA4InZzqB78qvr83z/9+k1G14DJSVgjIItwNKr\nP0TxlKKPC2DjIvc6rrDN+0vnklqCvOSjv/TfLLMG3xRk+XnFxhTewvG92NSt\nZaCaUmLl5gUMFFuWp+9ZF86tfFYdZaxul2ric4Zd0EWeKw8QmPWHZdZV50bF\nuNJAtmNuiTjl8F3/vX0sacdMHFnh720ABlZiywUJdadN+OLVKZTNE3iJF/eE\nNVZ6/pLjxDhUIpXz7mLpmEESFxRlygopQYu98KFh3rIOOEdZ6J2vHpXAt6m7\nulG8/eUR1uyYLadH3BHXYU/fidfIJbs5kIHv1HXivgZUslpTWMlGaQisNQ2M\nFzScCrUF0VaEhL11lQCroTdP7Dq2zvbry3MAIQa20Hm1G3w+iCaWjAQHggWK\nN1EKA0KyXORpH7xI62iSpPndVBtbSlJTJda42pUZFDp1Gpgfo36J1zwpzfNQ\nekiLIX4q3eovYYqthzKbCPDwKWCXbamYu97D68m/SaSwWaIiCURBT1ce9557\nABx5IOh9DN8/8csK7aJjKrBC4uLju5/x0dRYyCQH1PoiI8kgGrjcy3RqoCLg\n+tlTyMtCs7uFWg77q0S8uHXzG3eyYP0LGWuZqyJJiQrON1WRp7Syfghk01/T\nF4ml\r\n=lmQC\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCICexQkxRPcniQAbSHI0TSHrmKPeXvifhVQE3jGtODgfxAiEAm1WLsvZ/uSP4swBRt2zUQrf8Pj+pQHAmkOOtXg9PFjs="}],"size":2171,"noattachment":false,"key":"/compare-func/-/compare-func-2.0.0.tgz"},"maintainers":[{"name":"stevemao","email":"steve.mao@healthinteract.com.au"}],"_npmUser":{"name":"stevemao","email":"maochenyan@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/compare-func_2.0.0_1589549721737_0.64007997733769"},"_hasShrinkwrap":false,"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":1589549721878,"_cnpm_publish_time":1589549721878,"dist-tags":{"latest":"2.0.0"}}