sort array using another array code example
Example 1: sort array based on another array
arr.sort((a, b) =>{
return sortingArray.indexOf(a) - sortingArray.indexOf(b);
});
Example 2: sort arrays according to first array js
itemsArray.sort(function(a, b){
return sortingArr.indexOf(a) - sortingArr.indexOf(b);
});