My goal is to populate an array, by assigning empty arrays to its current values, and then removing original values, to finally get an array of arrays.
[ { id_menu_item: 3,
title: 'Preferences',
url: '/user/settings',
icon: 'settings',
is_parent: false,
id_parent: 1
},
{
id_menu_item: 4,
title: 'Log out',
url: '/logout',
icon: 'power_settings_new',
is_parent: false,
id_parent: 1
},
{
id_menu_item: 6,
title: 'Images',
url: null,
icon: 'collections',
is_parent: true,
id_parent: 5
} ]
I'm getting this array, and I need to sort it by id_parent. I have an array with the different id_parent (on this case, I have var ids = [1, 5]
)
I want to achieve the following:
[
1 = [
{..., id_parent = 1},
{..., id_parent = 1}],
5 = [
{..., id_parent = 5}
]]
where the ... are not spread operators, just omitting the rest of the object for clarity sake. Do you guys see what I mean more precisely now ?