Suppose I have two arrays, like this:
var SortedArray = [25, 123, 2464, 112, 54, 51, 347, 4572, 634];
var ArrayToSort = [634, 25, 51, 123];
SortedArray is an array that contains the order of many elements. ArrayToSort contains just some of the elements of SortedArray and every element in ArrayToSort is certain to also be in SortedArray.
What's the best way to sort ArrayToSort so that the elements in that array appear in the same order as SortedArray and get this result:
ArrayToSort = [25, 123, 51, 634];