aliroObjectSorter.php

Go to the documentation of this file.
00001 <?php
00002 
00006 class aliroObjectSorter {
00007     var $_keyname = '';
00008     var $_direction = 0;
00009     var $_object_array = array();
00010 
00011     public function __construct (&$a, $k, $sort_direction=1) {
00012         $this->_keyname = $k;
00013         $this->_direction = $sort_direction;
00014         $this->_object_array =& $a;
00015         $this->sort();
00016     }
00017 
00018     // This is not genuinely public, but has to be declared so for the callback
00019     public function aliroObjectCompare (&$a, &$b) {
00020         $key = $this->_keyname;
00021         if ($a->$key > $b->$key) return $this->_direction;
00022         if ($a->$key < $b->$key) return -$this->_direction;
00023         return 0;
00024     }
00025 
00026     private function sort () {
00027         usort($this->_object_array, array($this,'aliroObjectCompare'));
00028     }
00029 
00030 }

Generated on Wed May 14 13:01:56 2008 for ALIRO by  doxygen 1.5.5