I just posted a question here ( Sorting/Filtering from 2 arrays ) but I ran into a problem because my id's could be random strings:
so I have a master array with all the data :
var masterArray = [
{'id' : 'wedfd', 'title' : 'Title 1'},
{'id' : 'hji', 'title' : 'Title 2'},
{'id' : 'sdfds', 'title' : 'Title 3'},
{'id' : 'fgfgf', 'title' : 'Title 4'},
{'id' : 'kkd', 'title' : 'Title 5'},
{'id' : 'jjj', 'title' : 'Title 6'},
{'id' : 'abc', 'title' : 'Title 7'}
];
I get an array with this info :
var sortFilterInfo = [
{'id' : 'jjj', 'sortOrder' : 1},
{'id' : 'hji', 'sortOrder' : 2},
{'id' : 'abc', 'sortOrder' : 3}
]
With this information I need an array which gives me this sorted filtered array: ( I am only using native DOM Array methods (ES6) (map/filter/sort) and NOT Jquery,lodash, etc.
var resultArray = [
{'id' : 'jjj', 'title' : 'Title 6', 'sortOrder' : 1},
{'id' : 'hji', 'title' : 'Title 2', 'sortOrder' : 2},
{'id' : 'abc', 'title' : 'Title 7', 'sortOrder' : 3}
]
Thanks!