JSFiddle - React, Tailwind, and code Playground
by jfriend00
HTML
<div id="result"></div>
CSS
#result {font-family: "Courier New"; font-size: 11px;}
JavaScript
var data = {
a : {
timestamp: 11111,
other : "xxx"
},
b : {
timestamp: 22222,
other : "yyy"
},
c : {
timestamp: 33333,
other : "zzz"
}
};
var output = [];
// copy items to an array so they can be sorted
for (var key in data) {
data[key].key = key; // save key so you can access it from the array (will modify original data)
output.push(data[key]);
}
output.sort(function(a,b) {
return(a.timestamp - b.timestamp);
});
$("#result").append(JSON.stringify(output).replace(/\},\{/g, "},<br>{"));