예제 #1
0
 /**
  * Sort an array based datagrid
  */
 private function _sortArray($a, $b)
 {
     if (empty(Datagrid::$orderby)) {
         Datagrid::$orderby = key($a);
         Datagrid::$orderdir = 1;
         // Ascending
     }
     // Ascending
     if (Datagrid::$orderby['direction']) {
         if ($a[Datagrid::$orderby['column']] > $b[Datagrid::$orderby['column']]) {
             return 1;
         } elseif ($a[Datagrid::$orderby['column']] < $b[Datagrid::$orderby['column']]) {
             return -1;
         } else {
             return 0;
         }
         // Descending
     } else {
         if ($a[Datagrid::$orderby['column']] > $b[Datagrid::$orderby['column']]) {
             return -1;
         } elseif ($a[Datagrid::$orderby['column']] < $b[Datagrid::$orderby['column']]) {
             return 1;
         } else {
             return 0;
         }
     }
 }