{"action":"created","issue":{"url":"https://api.github.com/repos/lodash/lodash/issues/1459","repository_url":"https://api.github.com/repos/lodash/lodash","labels_url":"https://api.github.com/repos/lodash/lodash/issues/1459/labels{/name}","comments_url":"https://api.github.com/repos/lodash/lodash/issues/1459/comments","events_url":"https://api.github.com/repos/lodash/lodash/issues/1459/events","html_url":"https://github.com/lodash/lodash/issues/1459","id":106140378,"number":1459,"title":"How to get an object with all keys sorted?","user":{"login":"stanleyxu2005","id":5162687,"avatar_url":"https://avatars.githubusercontent.com/u/5162687?v=3","gravatar_id":"","url":"https://api.github.com/users/stanleyxu2005","html_url":"https://github.com/stanleyxu2005","followers_url":"https://api.github.com/users/stanleyxu2005/followers","following_url":"https://api.github.com/users/stanleyxu2005/following{/other_user}","gists_url":"https://api.github.com/users/stanleyxu2005/gists{/gist_id}","starred_url":"https://api.github.com/users/stanleyxu2005/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stanleyxu2005/subscriptions","organizations_url":"https://api.github.com/users/stanleyxu2005/orgs","repos_url":"https://api.github.com/users/stanleyxu2005/repos","events_url":"https://api.github.com/users/stanleyxu2005/events{/privacy}","received_events_url":"https://api.github.com/users/stanleyxu2005/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/lodash/lodash/labels/question","name":"question","color":"d4c5f9"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":9,"created_at":"2015-09-12T07:58:48Z","updated_at":"2016-06-16T06:30:50Z","closed_at":"2015-09-12T14:09:54Z","body":"Sometimes, I create an object (dictionary) with some index-able value as key. I want to make sure all keys are sorted alphabetically. Is there a built-in function of lodash to do that? Currently I have an own function to do that.\r\n```\r\nfunction objectWithKeySorted(object) {\r\n  var result = {};\r\n  _.forEach(Object.keys(object).sort(), function(key) {\r\n    result[key] = object[key];\r\n  });\r\n  return result;\r\n}\r\n```\r\nExample:\r\n```\r\nvar a = {2015: '2015', 2011: '2011', 2013: '2013'};\r\nconsole.log(a); // {2015: '2015', 2011: '2011', 2013: '2013'}\r\nvar b = objectWithKeySorted(a);\r\nconsole.log(b); // {2011: '2011', 2013: '2013', 2015: '2015'}\r\n```"},"comment":{"url":"https://api.github.com/repos/lodash/lodash/issues/comments/226399451","html_url":"https://github.com/lodash/lodash/issues/1459#issuecomment-226399451","issue_url":"https://api.github.com/repos/lodash/lodash/issues/1459","id":226399451,"user":{"login":"zorji","id":5819904,"avatar_url":"https://avatars.githubusercontent.com/u/5819904?v=3","gravatar_id":"","url":"https://api.github.com/users/zorji","html_url":"https://github.com/zorji","followers_url":"https://api.github.com/users/zorji/followers","following_url":"https://api.github.com/users/zorji/following{/other_user}","gists_url":"https://api.github.com/users/zorji/gists{/gist_id}","starred_url":"https://api.github.com/users/zorji/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zorji/subscriptions","organizations_url":"https://api.github.com/users/zorji/orgs","repos_url":"https://api.github.com/users/zorji/repos","events_url":"https://api.github.com/users/zorji/events{/privacy}","received_events_url":"https://api.github.com/users/zorji/received_events","type":"User","site_admin":false},"created_at":"2016-06-16T06:30:49Z","updated_at":"2016-06-16T06:30:49Z","body":"`_(obj).map((v, k) => [k, v]).sortBy(0).fromPairs().value()`"}}
{"actor":{"display_login":"zorji"}}