This is an example of an array that I am trying to sort by the key match_points
(descending):
Let the array printed below be called $my_arr
.
Array
(
[0] => Array
(
[0] => Array
(
[109] => 92
[match_points] => 50
)
)
[1] => Array
(
[0] => Array
(
[16] => 12
[match_points] => 62
)
)
[2] => Array
(
[0] => Array
(
[80] => 51
[match_points] => 63
)
)
)
I tried this:
$a = usort($my_arr,
function (array $a, array $b) {
return $a["match_points"] - $b["match_points"];
}
);
But I am getting this warning message:
Undefined index: match_points
This post did not explicitly show how to sort a 3 dimensional array by a specific key, although the answer can be inferred after reading that post.