I am trying to sort an array of objects with Usort. When I run the function it does not fully sort the array. Not quite sure what I am doing wrong. I am trying to sort this based on 'zone_total' But it's not giving the result that I am looking for. I am looking to sort this with 1 value not 2. So I cannot use array_msort.(I believe this sorts it based on 2 values.)
Here is the data that I am working with.
[0] => stdClass Object
(
[class] => 6
[zone_total] => 118
)
[1] => stdClass Object
(
[class] => 1
[zone_total] => 12
)
Here is my code
usort($leaders, array($this, "cmp"));
public function cmp($a, $b)
{
return strcmp($a->zone_total, $b->zone_total);
}