Within my code, I have two arrays of objects, both containing a "columnId" property. My goal is to rearrange the first array to match the order of the second.
I attempted the following method:
filtered = visibleColumns.filter(function(v) {
return filtered.includes(v.colId);
});
Although 'filtered' is supposed to be the resulting array and 'visibleColumns' represents the desired order, this approach did not yield the expected outcome.
Here are examples of the arrays:
filtered = [{
colId:1,
title: 'col1',
size: 10
},
{
colId:2,
title: 'col2',
size: 10
}];
visibleColumns = [{
colId:2,
visible: true
},
{
colId:1,
visible: true
}];