I have an array of objects that looks like this.
var items = [
{id: 1150, title: 'im tyler'},
{id: 1195, title: 'im josh'}
];
And another array that looks like this:
var sortArray = [
'1195',
'1150'
];
What i am trying to accomplish is a sorting based on result from the sort array. So in this scenario that items array should sort the object with id = 1195 as first in the list. Also if there is only one id in the sortArray it should only display that object in the items array.
Wanted result:
var Newitems = [
{id: 1195, title: 'im josh'}
{id: 1150, title: 'im tyler'},
];