I have this data below with I want to push into an array but ordering it by name(x)
Here is the data:
params:
name2:
height: 2
name0:
height: 0
name1:
height: 3
And here is the code:
data.f = []
Object.keys(data.params).forEach((key, idx) => {
data.f.push({
...data.params[key],
name: `${idx} - ${key}`
});
})
At the moment it's just pushing it into the array as it reads it but it's not ordered.
How can I order it either whiles it's read or after it's been populated?