I have the following object:
Object {
"1468": "Test Prop",
"1647": "TEST 1",
"1820": "ABC",
"1840": "Gio"
}
I would like to order by the second property. It would be:
Object {
"1820": "ABC",
"1840": "Gio",
"1647": "TEST 1",
"1468": "Test Prop"
}
How can I do it in Javascript?
I received the data in an array:
Array [
Array [
1820,
"ABC",
],
Array [
1840,
"Gio",
],
Array [
1647,
"Test 1",
],
Array [
1468,
"Test Prop",
],
]
It is already ordered, but when I create my object I lost the order:
const myObj = {};
for (let index = 0; index < data.length; ++index) {
const value = data[index];
myObj[value[0]] = value[1];
}
Thanks