/**
  * Check and set data to sort return comparation function
  * $field field to compare
  * $descending order
  */
 public static function set_order($field, $ascending = true)
 {
     $sortfields = array('name' => array('name'), 'shortdescription' => array('shortdescription'), 'startdate' => array('startdate', 'duedate', 'name'), 'duedate' => array('duedate', 'startdate', 'name'), 'automaticgrading' => array('automaticgrading', 'duedate', 'name'));
     if (isset($sortfields[$field])) {
         self::$fields = $sortfields[$field];
     } else {
         //Unknow field
         self::$fields = $sortfields['duedate'];
     }
     if ($ascending) {
         self::$ascending = -1;
     } else {
         self::$ascending = 1;
     }
 }