Campustream 1.0
A social network MQP for WPI
application/lib/util.php
Go to the documentation of this file.
00001 <?
00002 
00003 class util {
00004         
00005         public static function objectSort(&$data, $key) {
00006             for ($i = count($data) - 1; $i >= 0; $i--) {
00007                         $swapped = false;
00008                 for ($j = 0; $j < $i; $j++) {
00009                      if ($data[$j]->$key > $data[$j + 1]->$key) { 
00010                           $tmp = $data[$j];
00011                           $data[$j] = $data[$j + 1];        
00012                           $data[$j + 1] = $tmp;
00013                           $swapped = true;
00014                      }
00015                 }
00016       
00017                         if (!$swapped) return;
00018                 }
00019         }
00020 }