function CourseList::sort_degree_requirement_id

7.x CourseList.php CourseList::sort_degree_requirement_id()
6.x CourseList.php CourseList::sort_degree_requirement_id()

Sorts the courses based on their db_degree_requirement_id value

File

classes/CourseList.php, line 1288

Class

CourseList

Code

function sort_degree_requirement_id() {

  $sort_list = array();

  // go through the courses, creating an array keyed by db_degree_requirement_id.
  for ($t = 0; $t < count($this->array_list); $t++) {
    $id = intval($this->array_list [$t]->db_degree_requirement_id);

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

  //sort the array in order ascending
  ksort($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();


}