I have an application where I want to be able to render a stack of content based on an orderId value in the object.
{
"hero": {
"body": "test body",
"orderId": 1
},
"journey": {
"body": "test body",
"orderId": 0
},
"banner": {
"body": "test body",
"orderId": 2
}
}
- create an array of the keys based on the orderId in the object ["Journey", "Hero", "Banner"]
- be able to order this object by orderId
I've tried something like this for the creating the array
Object.entries(content).sort(function(a, b) {
return a[1].orderId - b[1].orderId;
});