I receive data from a REST API, which contains id
and name
properties ordered by name
. The data is:
Array [
Array [
960,
"",
],
Array [
588,
" Computer Associate System, LLC",
],
Array [
481,
"1111",
],
Array [
91,
"123Inkjets",
],
Array [
73,
"1and1 Internet",
],
]
Then, I want to create an object that still ordered by name:
const vendors = {};
const data = response.data.DATA;
if (data !== undefined) {
for (let index = 0; index < data.length; ++index) {
const value = data[index];
vendors[value[0]] = value[1];
}
}
However, the result of vendors
is not ordered by the name. How can I order it? I still need to return vendors as an object with "id" : "name"
Thanks