The array is incorrectly sorted by date. If the data is selected from 2014-06-01 to 2015-02-15, it sorts only by month, from January to December (2015 goes ahead, then 2014).
I used several functions - the same thing.
function sort1($a, $b){ if (strtotime($a['DATE']) > strtotime($b['DATE'])) return 1; } function sort3($a, $b){ if (strtotime($a['DATE']) === strtotime($b['DATE'])) return 0; return (strtotime($a['DATE']) > strtotime($b['DATE']))?1:-1; } function sort2($a, $b){ $aa = explode("-", $a['DATE']); $ba = explode("-", $b['DATE']); if($aa[2]>$ba[2])return 1; if($aa[2]<$ba[2])return -1; if($aa[1]>$ba[1])return 1; if($aa[1]<$ba[1])return -1; if($aa[0]>$ba[0])return 1; if($aa[0]<$ba[0])return -1; return 0; } $rows_array[0]['DATE']= "2015-01-01"; $rows_array[0]['NAME']= "Vasya"; $rows_array[1]['DATE']= "2014-01-01"; $rows_array[2]['NAME']= "Kolya"; // итд usort($rows_array, 'sort3');