I have an array of unique values specified in some arbitrary order; I have another array of (nearly) the same values as the first array, but some values may be missing, and they are ordered in a completely different way.
How do I order values in the second array in the same order as the first one?
UPD for example:
array 1: 4, 8, 2, 5, 9, 3
array 2: 5, 8, 4, 2
required result: 4, 8, 2, 5