I\'m currently trying to sort a multidimensional array by its subvalues. The structure of the array is:
[0] => Array ( [id] => 87 [
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; } );