I have multiple arrays in in this format:
array = array(
[0] => String
[1] => String
[2] => 1234
)
All of these arrays are contained in a single array. Is there any way i could sort each array in the Main array by the Number [2] from Highest to lowest. I have seen things like rsort()
, but never got them to work. Thanks.
I just tried this, but it does not work for the last array?
function sortByOrder($a, $b) {
return $a[1] - $b[1];
}
$array = array(array("sdfdf", "dddfg", 153), array("dd", "dd", 80), array("dd", "ddd", 155));
usort($array, 'sortByOrder');
print_r($array);