usort Issues

[php]
public static function orderConsumers($outbound,$inbound)
{
$a = $outbound->outTotal;
$b = $inbound->inTotal;

if ($a == $b) {
return 0;
}
return ($a < $b) ? 1 : -1;

}

[/php]

Its sorting a list of inbound and outbound traffic within the same object. It is sorting but not correctly.
**** are users , the numbers are the highest # of inbound or outbound traffic
(****) 7,541.11 (OUTBOUND)
() 10,037.45 (INBOUND)
(
) 6,901.45 (INBOUND)
(
**) 7,070.75 (INBOUND)

I need it to be from highest to lowest

Any Ideas why this is not sorting correctly?

i dont know if I quite understand this correctly but did you try reversing this:
return ($a < $b) ? 1 : -1;
to
return ($a > $b) ? 1 : +1;

:smiley:

Sponsor our Newsletter | Privacy Policy | Terms of Service