Skip to content

Instantly share code, notes, and snippets.

@rumf
Last active December 12, 2015 00:28
Show Gist options
  • Save rumf/4683659 to your computer and use it in GitHub Desktop.
Save rumf/4683659 to your computer and use it in GitHub Desktop.
sortObject = function(o) {
var sorted = {},
key, a = [];
for (key in o) {
if (o.hasOwnProperty(key)) {
a.push(key);
}
}
a.sort();
for (key = 0; key < a.length; key++) {
sorted[a[key]] = o[a[key]];
}
return sorted;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment