If have a rather basic uasort
function in PHP that looks like this:
uasort($arr, function($a, $b) {
if ($a > $b)
return -1;
if ($a < $b)
return 1;
...
}
The array I'm trying to sort looks like the following:
{[1642] => 1, [9314] => 4, [1634] => 3 ...}
It contains integers that are my main comparison criteria. However, if the integers are equal, then I would like to access their key values, inside the uasort
function and do some magic with it to figure out the sorting from there.
I have no clue how to do that as it seems that the $a
and $b
variables that get passed into the function are just the integers without the corresponding keys but there should be a way to access the key as well since I'm using a function to actually preserve the keys. Any ideas?