Sort JavaScript object by key
Object.keys(unordered).sort().forEach(function(key) { var value = unordered[key]; delete unordered[key]; unordered[key] = value; }); // http://stackoverflow.com/questions/5467129/sort-javascript-object-by-key