{"name":"sort-object","description":"Sort the keys in an object","version":"0.0.2","homepage":"https://github.com/helpers/sort-object","author":{"name":"Assemble","url":"https://github.com/assemble"},"repository":{"type":"git","url":"https://github.com/helpers/sort-object.git"},"bugs":{"url":"https://github.com/helpers/sort-object/issues"},"licenses":[{"type":"MIT","url":"https://github.com/helpers/sort-object/blob/master/LICENSE-MIT"}],"main":"sort-object.js","engines":{"node":">= 0.8.0"},"keywords":["sort","sort object","sort object keys","sort object by keys","javascript sort"],"dependencies":{"lodash.assign":"~2.2.1","lodash.keys":"~2.2.1"},"devDependencies":{"mocha":"~1.13.0"},"_id":"sort-object@0.0.2","dist":{"shasum":"af8aff32585111073dbdb72f2fd7c0c40ef63b5c","tarball":"http://registry-npm.ywwl.com/sort-object/download/sort-object-0.0.2.tgz","integrity":"sha512-I0wCfQAAkZux+GhiZj3OMWCiuFRrX+QTeljlSvK7A/30XyAkvIIOv8E1GEWbhDQCBHuHMMP0EavUtAvIwq6c3Q==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDFXT8N843I5/YIEvljYcM3rKJvJI+hVfR8+zkDuesHugIgC+VnL+kqoMZ5gPtjcCA/7srFHCTeCWXOUQ8u9c7kBR8="}],"size":2318,"noattachment":false,"key":"/sort-object/-/sort-object-0.0.2.tgz"},"_from":".","_npmVersion":"1.3.5","_npmUser":{"name":"doowb","email":"brian.woodward@gmail.com"},"maintainers":[{"name":"doowb","email":"brian.woodward@gmail.com"}],"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":1380883321414,"_cnpm_publish_time":1380883321414,"dist-tags":{"latest":"3.0.3"}}