so I have two arrays. one of them looks like this (it's values or the number of elements can change):
array('4dec' , 'def3', 'a3d6', 'd12f');
and the other:
array(array('id' => 'd12f', 'name' => 'John'),
array('id' => 'a5f1', 'name' => 'Kathy'),
array('id' => 'def3', 'name' => 'Jane'),
array('id' => 'a3d6', 'name' => 'Amy'),
array('id' => '4dec', 'name' => 'Mary'),
array('id' => 'ecc2', 'name' => 'Fred'));
(this one shouldn't change, elements and values are the same every time).
notice the first one has a few elements from the 2nd one. How can I sort the 2nd array based on the elements from the 1st one?
so basically, in this case the 2nd array should become:
array(array('id' => '4dec', 'name' => 'Mary'),
array('id' => 'def3', 'name' => 'Jane'),
array('id' => 'a3d6', 'name' => 'Amy'),
array('id' => 'd12f', 'name' => 'John'),
array('id' => 'a5f1', 'name' => 'Kathy'),
array('id' => 'ecc2', 'name' => 'Fred'));
(the elements that exist in the 1st one are moved at the top, in the same order as the 1st, and the others are left alone).