I have two array of strings: one ordered array - Array X, and one unordered array - array Y
What the new array should have: all items should only be from array Y, and the ones that overlap between X and Y should be ordered based on the order in X, and then the rest (if any) should just be at the end in the same order as they were originally in Y. It is possible that X contains entries that are not in Y, and we just want to ignore those.
What is an efficient way of doing this (in php)?
Example:
Array X: {'a', 'z', 'q', 'd'}
Array Y: {'b', 'c', 'a', 'd', 'z'}
Result: {'a', 'z', 'd', 'b', 'c'}
So the idea is: we want to take the 2nd array (array Y), and sort the elements in it based on the ordering given to us in array X. Since Array Y might have more extra elements, we just want to put those extra elements at the end of this new resultant array. Makes sense?