{"name":"compare-func","version":"1.3.3","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":"^2.5.1"},"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":"ba4a5e0c416b4a65f37ffd75f05c17fd8bf069c0","bugs":{"url":"https://github.com/stevemao/compare-func/issues"},"_id":"compare-func@1.3.3","_nodeVersion":"12.16.1","_npmVersion":"6.13.4","dist":{"integrity":"sha512-h6V4KnFKU7rovduMM6HLFvf13+dq+JeN8thEWg5qqpF91NTKnTT7j0Rq7A2q+XhXs3awXeUAeKiJFoqTfWZKUw==","shasum":"eec550dcc84c78c037517626c79ce3abba1c1b5b","tarball":"http://registry-npm.ywwl.com/compare-func/download/compare-func-1.3.3.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\nwsFcBAEBCAAQBQJevpi3CRA9TVsSAnZWagAAsVwQAJrl3ZzU4QRQBTzpgT0K\n3GggRJGfxf/cqTvadO3QX3n5IDn0yA944CiC2uekl+M/8j90nTxMivYAzAqk\nbDjOOr9rlHZcoJkTJY9U+IzkF7H448CIFSIw7H4IdyJ7oFGhhYv9n/4bx0g8\n58IfYwxjzGatNxnSO+4KseXH+ndDeRObaWErZOsri5+rTt9nt/VPlubphzk6\n5CkypczsxrY1M44iRTilbSZkkQ3ocGLJfmJZmD8NOrvFnRwswDqgf66618GR\n7rYYguBNbat+7O5JgD9PPlyyMMPePYPNJ47uyuO5vnGBaiWwiyK5lcUooZXY\nlfbm5PGAEf0xuhfTKcF1lJie/1JoYl6Xq1gmzo4Vw4plfzphMewlKtl2SijT\nqhssmvRRGjWNEV6HQzm6rckk1t+ccJk56d5WYFuCgwrmd3m/ljNMAcL+J6QU\n1Y3EEGyFK7pHxkrkVuN8G6r8+IwberU0mmX4mPembxxnaiQfqGFDjElO3biX\nYoe+dVKB238j7oO9kfS0SfLvrhli0AZofF41FMm15CTz8TBepI1j5PkpRKxx\nYypaRSRFHvQ286g2DToR46g/yvYofW8Zo9lKNzvkEQrahWg9efBMrZyXbAbf\nPeF1JRvXRxJIa/vEYXgo0CMo9RQPjELE3YsWl+9bQYpRqJ1ub0gUXXh/iwxw\nTPD+\r\n=2VC6\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIGXsL9xQhx6UZ4ine8+yDm2gbfFvLCCadqHYCIp+4X80AiEAoCRuVVB6bykwHKQJ0qqyhrwktaOGlO3FHAV2Ka4UMTc="}],"size":2171,"noattachment":false,"key":"/compare-func/-/compare-func-1.3.3.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_1.3.3_1589549239237_0.4028682486255428"},"_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":1589549239409,"_cnpm_publish_time":1589549239409,"dist-tags":{"latest":"2.0.0"}}