usort descending

My first guess is that usort expects an integer response, and will round off your return values if they are not integers. In the case of 0.29, when it is compared to 0, the result is 0.29 (or -0.29), which rounds off to 0. For usort, 0 means the two values are equal.

Try something like this instead:

usort($myArray, function($a, $b) {
    if($a['order']==$b['order']) return 0;
    return $a['order'] < $b['order']?1:-1;
});

(I think that's the correct direction. To reverse the order, change the < to >)


Just switch the $a and $b around as follows;

function sort($a, $b){ 
return strcasecmp($b->order, $a->order);
}
usort($myArray, "sort");

using the space ship operator in php 7 (and over):

usort($myArray, function($a, $b) {
    return $a['order'] <=> $b['order'];
});

would return the array sorted in ascending order. reversing the comparison will return it in descending.

usort($myArray, function($a, $b) {
    return $b['order'] <=> $a['order'];
});