function _CourseList::sort_largest_hours_first

5.x _CourseList.php _CourseList::sort_largest_hours_first()

File

classes/_CourseList.php, line 1227

Class

_CourseList

Code

function sort_largest_hours_first() {
  $sort_list = array();

  // go through the courses, creating an array keyed by hours.
  for ($t = 0; $t < count($this->array_list); $t++) {
    $hrs = $this->array_list [$t]->get_hours();
    if ($this->array_list [$t]->bool_ghost_hour) {
      $hrs = 0;
    }

    $sort_list [$hrs][] = $this->array_list [$t];
  }

  //sort the array in order of hours descending
  krsort($sort_list, SORT_NUMERIC);

  //clear the internal array, then refill it with the now sorted courses.
  $this->array_list = array();
  foreach ($sort_list as $courses) {
    foreach ($courses as $course) {
      $this->array_list [] = $course;
    }
  }
  $this->reset_counter();
}