function _CourseList::sort_advised_last_alphabetical

4.x _CourseList.php _CourseList::sort_advised_last_alphabetical()
5.x _CourseList.php _CourseList::sort_advised_last_alphabetical()

This re-sorts the CourseList so that advised courses are last, in alphabetical order, preceeded by unfulfilled courses, in alphabetical order.

File

classes/_CourseList.php, line 666

Class

_CourseList

Code

function sort_advised_last_alphabetical() 
 {

  $tarray = array();
  for ($t = 0; $t < $this->count; $t++) 
   {
    if ($this->array_list [$t]->bool_advised_to_take == true) 
     { // Skip if not fulfilled.
      continue;
    }

    $c = $this->array_list [$t];
    $str = "$c->subject_id ~~ $c->course_num ~~ $t";
    array_push($tarray, $str);
  }

  sort($tarray);


  // Alright, now we do it again, but with advised courses.
  $t2array = array();
  for ($t = 0; $t < $this->count; $t++) 
   {
    if ($this->array_list [$t]->bool_advised_to_take == false) 
     { // Skip if not advised
      continue;
    }

    $c = $this->array_list [$t];
    $str = "$c->subject_id ~~ $c->course_num ~~ $t";
    array_push($t2array, $str);
  }

  sort($t2array);

  $t3array = array_merge($tarray, $t2array);

  $new_list = new CourseList();
  for ($t = 0; $t < count($t3array); $t++) 
   {
    $temp = explode(" ~~ ", $t3array [$t]);
    $i = $temp [2];

    $new_list->add($this->array_list [$i]);
  }

  // And, transfer the newList into this list.
  $this->array_list = $new_list->array_list;


}