Basically I have an array with:
that I fill with an SQL query. This makes the array like:
I want to create another array where the key of the array objects is the first element of the objects inside organisations, so they would be id1, id2 etc etc.
I think the output should be like:
newArray = [id1: {name1, type2}, id2: {name2, type2}]
organisation_ids = organisations.map(x => x.id)?sortthe Array:organisations.sort((a,b) => a.id - b.id), so you dont have to rely on the 'key', which should be sequential in an array, otherwise its an object.Setor sth link. And your array notation is not valid. It can be like this :[ {id1: {name1, type2}}, {id2: {name2, type2}}], but i'm not sure it is what you want.