JSFiddle - React, Tailwind, and code Playground
by Udhay
JavaScript
myArray = [
{0: "one", 1:{title:'hardware', list:{0:'one',1:'two'}}},
{0: "two", 1:{title:'software', list:{0:'twotwo',2:'threethree'}}},
{0: "three", 1:{title:'software', list:{0:'three33',2:'fourfour'}}}
];
var res = myArray.reduce(function(res, currentValue) {
if ( res.indexOf(currentValue[1].title) === -1 ) {
res.push(currentValue[1].title);
}
return res;
}, []).map(function(group) {
return {
group: group,
resource: myArray.filter(function(_el) {
return _el[1].title === group;
}).map(function(_el) { return [_el[0], _el[1].list]; })
}
});
console.log(res);