This should do it.
$a1 = array(2, 1, 4, 0, 3);
$a2 = array("Sally", "Jill", "frank", "greg", "Korean_Jesus");
$sorted = array();
for ($i=0; $i<count($a1); $i+=1) {
/* $a1[$i] is the index in the final array. Simple assignment. */
$sorted[$a1[$i]] = $a2[$i];
}
/* $sorted = array("greg", "Jill", "Sally", "Korean Jesus", "frank") */
It may be worth checking the arrays are the same length and that values of one correspond to indices of the other unless you have good reason to believe that will never happen.