So if I had 2 columns in a object
A -> values are 10 8 6 4
B -> values are 9 7 5 3
I want to merge B into A with 9 below 10, 7 below 8 etc.
uasort($TopConsumers,array('Utilities','orderconsumers'));
public static function orderConsumers($TopConsumers)
{
$a = $TopConsumers->outTotal;
$b = $TopConsumers->inTotal;
if ($a == $b) {
return 0;
}
return ($a > $b) ? -1 : +1;
}
Why is this not working?
Your sorting function needs to have $a and $b as arguments to it. Not the array itself.
That said it seems a little odd to sort by two columns. I’m not sure this is going to give you what you’re looking for. Normally you’d compare the same column name in a user sort function like that.