I have a JS object that has the following snippet:
{
"foo": "bar",
"baz": [
{
"order": 2,
"fruit": "banana"
},
{
"order": 1,
"fruit": "apple"
},
{
"order": 3,
"fruit": "peach"
},
]
}
My goal is to be able to iterate through all the objects in "baz" but in the order according to their "order" property, not the order as stored in the object. The order of the objects in "baz" can/will change frequently, so sorting them previously or storing them in the order they need to be in is not an option.
A pure JS or jQuery answer is all acceptable.