Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Sort object by key
* Sort object by key
* @param unordered object
* @returns {Object} ordered object by key
function sortObject(unordered) {
var ordered = {};
Object.keys(unordered).sort().forEach(function (key) {
ordered[key] = unordered[key];
return ordered;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment