I used array_intersect in order to sort an array arbitrarly:
<?php
$a = array('one', 'two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten');
$b = array('four', 'one', 'height', 'five')
var_dump(array_intersect($a, $b);
?>
will output:
0 => 'one'
1 => 'four'
2 => 'five'
3 => 'height'
i hope this can help...