usort issue with decimal numbers
See usort docs. Float result will be converted to integer. For correct work use this code:
usort(
$data,
function($a, $b) {
$result = 0;
if ($a[$_GET['sortby']] > $b[$_GET['sortby']]) {
$result = 1;
} else if ($a[$_GET['sortby']] < $b[$_GET['sortby']]) {
$result = -1;
}
return $result;
}
);
Try strnatcmp():
usort($output, function($a, $b) {
return strnatcmp($b->days_left, $a->days_left);
});