I am using this usort function to sort the array by value:
function cmp($a, $b)
{
if ($a["value"] == $b["value"])
{ return 0; }
return ($a["value"] < $b["value"]) ? -1 : 1;
}
Now, each object also has an “active” field as well, that is: $a[“active”]. I would like to have the sorted array to have first the active ones (1) ordered by value, then, when all of them are sorted, the inactive (0) ones. I tried using another usort after this but it doesn’t work nicely, it somewhat scrambles them.
Thanks in advance.
Untested – but I think it’ll work.
A good resource for this sort of stuff (but not this particular example, unfortunately for you): http://www.the-art-of-web.com/php/sortarray/