This usort function is returning the array reverse from what I want. It's returning an array like ("1", "2", "3"). How can I make it return ("3", "2", "1")?
usort($myArray, function($a, $b) {
return $a["comments"] - $b["comments"];
});
This usort function is returning the array reverse from what I want. It's returning an array like ("1", "2", "3"). How can I make it return ("3", "2", "1")?
usort($myArray, function($a, $b) {
return $a["comments"] - $b["comments"];
});
Just reverse the parameters?
usort($myArray, function($a, $b) {
return $b["comments"] - $a["comments"];
});