function _GroupList::sort_alphabetical_order

4.x _GroupList.php _GroupList::sort_alphabetical_order($bool_reverse_order = false)
5.x _GroupList.php _GroupList::sort_alphabetical_order($bool_reverse_order = false)

File

classes/_GroupList.php, line 129

Class

_GroupList

Code

function sort_alphabetical_order($bool_reverse_order = false) 
 {

  $tarray = array();
  // Since I need the indexes, I will have to go through the array
  // myself...
  for ($t = 0; $t < count($this->array_list); $t++) 
   {
    $g = $this->array_list [$t];
    $g->load_descriptive_data();
    $str = "$g->title ~~ $t";

    array_push($tarray, $str);
  }

  if ($bool_reverse_order == true) 
   {
    rsort($tarray);
  }
  else {
    sort($tarray);
  }

  // Now, convert the array back into a list of groups.
  $new_list = new GroupList();
  for ($t = 0; $t < count($tarray); $t++) 
   {
    $temp = explode(" ~~ ", $tarray [$t]);
    $i = $temp [1];

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

  // Okay, now $new_list should contain the correct values.
  // We will transfer over the reference.
  $this->array_list = $new_list->array_list;


}