I have an Array of Objects:
data = [
{
type: "displayName"
base: {}
staged: {}
},
{
type: "bots"
base: {}
staged: {}
},
{
type: "bots"
base: {}
staged: {}
},
{
type: "whiteList"
base: {}
staged: {}
}
]
I then have a array I would like to use to order my data array:
order = ["bots", "whiteList", "displayName"]
I need to order data based off each objects type
I have tried:
private orderChanges = (data: any[], order: any[]) => {
const orderedArray = [];
let len = Object.keys(data).length;
for (; len-- ;) {
const current = data[len];
const index = order.indexOf(current.resourceType);
orderedArray[index] = current;
}
return orderedArray;
}
While this works is will only return a single type->bots object in orderedArray.
Thanks!
'whitelist'is different from'whiteList'.