I have N number of arrays (eg. 3 arrays):
$arr1 = array(0 => array('id' => 34, 'score' => 440),
1 => array('id' => 32, 'score' => 140),
2 => array('id' => 22, 'score' => 121),
3 => array('id' => 99, 'score' => 532)
);
$arr2 = array(0 => array('id' => 32, 'score' => 213),
1 => array('id' => 34, 'score' => 354),
2 => array('id' => 22, 'score' => 674)
);
$arr3 = array(0 => array('id' => 34, 'score' => 10),
1 => array('id' => 22, 'score' => 449),
2 => array('id' => 99, 'score' => 586),
3 => array('id' => 32, 'score' => 113),
4 => array('id' => 16, 'score' => 777)
);
I want to sort these (N) arrays depending on (id) and (score) but i want to give the priority to the repetition id occurrence in all arrays and then the second priority to the max score, and the result will be (1) filtered unique array which holds unique ids according to these rules of sort.
I tried to do this using php usort
function to pass comparison function but i failed to do the job.