{"name":"sort-object","description":"Sort the keys in an object.","version":"2.0.0","homepage":"https://github.com/doowb/sort-object","author":{"name":"Brian Woodward","url":"https://github.com/doowb"},"repository":{"type":"git","url":"git://github.com/doowb/sort-object.git"},"bugs":{"url":"https://github.com/doowb/sort-object/issues"},"files":["index.js"],"maintainers":[{"name":"doowb","email":"brian.woodward@gmail.com"},{"name":"jonschlinkert","email":"github@sellside.com"}],"license":{"type":"MIT","url":"https://github.com/doowb/sort-object/blob/master/LICENSE"},"main":"index.js","engines":{"node":">=0.10.0"},"scripts":{"test":"mocha -R spec"},"devDependencies":{"mocha":"*","should":"^4.0.4"},"dependencies":{"get-value":"^1.1.5","sort-asc":"^0.1.0","sort-desc":"^0.1.1"},"keywords":["arr","array","function","js","key","keys","obj","object","order","re","re-order","sort","util","utils"],"gitHead":"ffca50c9d9aeb3be81b4a247e74cff0225bed0de","_id":"sort-object@2.0.0","_shasum":"8b586226427e176e7f2e1268c5f452f124b69086","_from":".","_npmVersion":"2.5.1","_nodeVersion":"0.12.0","_npmUser":{"name":"doowb","email":"brian.woodward@gmail.com"},"dist":{"shasum":"8b586226427e176e7f2e1268c5f452f124b69086","tarball":"http://registry-npm.ywwl.com/sort-object/download/sort-object-2.0.0.tgz","integrity":"sha512-PXfSSGI08k2E1/nOGEv8NOZi3xnQqo5hlA/76CTCxx2tDyPpZeDJ2l0tOqIMmq1a0JNWw+BdwhAWi8Z8+G+Wfg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDPeIpl5X9YeCQkaUSow56kl8o916GQiW7Z8x8BhOfzjQIgVt7MPbl2fRb+mc6IxjrDxa7tqxggXcJlbpvSvmGJ+9k="}],"size":2803,"noattachment":false,"key":"/sort-object/-/sort-object-2.0.0.tgz"},"directories":{},"readme":"# sort-object [![NPM version](https://img.shields.io/npm/v/sort-object.svg)](https://www.npmjs.com/package/sort-object) [![Build Status](https://img.shields.io/travis/doowb/sort-object.svg)](https://travis-ci.org/doowb/sort-object)\n\n> Sort the keys in an object.\n\n## Install\n\nInstall with [npm](https://www.npmjs.com/):\n\n```sh\n$ npm i sort-object --save\n```\n\n## Usage\n\n```js\nvar sortObj = require('sort-object');\n```\n\nBy default, the keys on an object will be sorted in ascending order:\n\n```js\nsortObj({a: 1, c: 2, b: 3});\n//=> {a: 1, b: 3, c: 2}\n```\n\nThe second param can be an object of `options` OR an array of `keys`:\n\n**object**\n\n```js\nsortObj({a: 1, c: 2, b: 3}, {keys: ['a', 'b']});\n//=> {a: 1, b: 3}\n```\n\n**array**\n\n```js\nsortObj({a: 1, c: 2, b: 3}, ['a', 'c']);\n//=> {a: 1, c: 2}\n```\n\n## Options\n\n* `keys` {Array} The returned object will contain only the specified keys, in the same order.\n* `sort` {Function} Sort function to sort the keys using JavaScript's `.sort()` method.\n* `sortOrder` {String} Valid values are `desc` or `asc`, case insensitive.\n* `sortBy` {String} Sort function that is passed the entire object, rather than just the keys - as with the `.sort()` method.\n\n### options.keys\n\nCreate a new object with only the given keys.\n\n```js\nvar o = {a: 1, c: 2, e: 5, d: 4, b: 3};\nsortObj(o, {keys: ['a', 'b']});\n\n//=> {a: 1, b: 3}\n```\n\n### options.sort\n\nFunction to be passed to javascript's `.sort()` method:\n\n```js\nvar o = {a: 1, c: 2, e: 5, d: 4, b: 3};\nvar obj = sortObj(o, {\n  sort: function (a, b) {\n    return a < b ? -1 : 1;\n  }\n});\nobj;\n//=> {a: 1, b: 3, c: 2, d: 4, e: 5}\n```\n\n### options.sortOrder\n\nValid values are `desc` or `asc`, case insensitive:\n\n```js\nvar o = {a: 1, c: 2, e: 5, d: 4, b: 3};\nsortObj(o, {sortOrder: 'ASC'});\n//=> {e: 5, d: 4, c: 3, b: 2, a: 1}\n```\n\n### options.sortBy\n\nFunction that returns an array of keys to sort by:\n\n```js\nvar old = {one: 'aa', two: 'bc', three: 'ab'};\nvar o = sortObj(old, {\n  sortBy: function (obj) {\n    var arr = [];\n    Object.keys(obj).filter(function(key) {\n      if (/^a/.test(obj[key])) arr.push(key);\n    });\n    return arr.reverse();\n  }\n});\n//=> {three: 'ab', one: 'aa'}\n```\n\n## Author\n**Brian Woodward**\n\n+ [github/doowb](https://github.com/doowb)\n+ [twitter/doowb](http://twitter.com/doowb)\n\n## License\nCopyright © 2014-2016 [Brian Woodward](https://github.com/doowb)\nReleased under the MIT license.\n\n***\n\n_This file was generated by [verb](https://github.com/verbose/verb) on February 03, 2016._\n","publish_time":1435635514672,"_cnpm_publish_time":1435635514672,"dist-tags":{"latest":"3.0.3"}}