Why does the usort function in the following snippet sort the matrix not only by the values of the 'num' keys in descending order, but then also sorts the elements with equal values of the 'num' keys by the values of the 'lett' keys in ascending order?How can I make it sort by only what is given in the body of the function?
<?php
$mtx = [["num"=>1,"lett"=>"f"],
["num"=>3,"lett"=>"b"],
["num"=>3,"lett"=>"a"]
];
usort($mtx, function($a,$b) {
if($a['num']<$b['num']) return 1;
if($a['num']>$b['num']) return -1;
});
var_dump($mtx);
/*
array(3) { [0]=> array(2) { ["num"]=> int(3) ["lett"]=> string(1) "a" }
[1]=> array(2) { ["num"]=> int(3) ["lett"]=> string(1) "b" }
[2]=> array(2) { ["num"]=> int(1) ["lett"]=> string(1) "f" }
}
*/