note 109003 deleted from function.usort by danbrown

From: Date: Wed, 13 Jun 2012 15:26:03 +0000
Subject: note 109003 deleted from function.usort by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-188573@lists.php.net to get a copy of this message
Note Submitter: biswarupadhikari at gmail dot com ---- function PHPArrayObjectSorter($array,$sortBy,$direction='asc') { $sortedArray=array(); $tmpArray=array(); foreach($this->$array as $obj) { $tmpArray[]=$obj->$sortBy; } if($direction=='asc'){ asort($tmpArray); }else{ arsort($tmpArray); } foreach($tmpArray as $k=>$tmp){ $sortedArray[]=$array[$k]; } return $sortedArray; } e.g => $myAscSoretedArrayObject=PHPArrayObjectSorter($unsortedarray,$totalMarks,'asc'); $myDescSoretedArrayObject=PHPArrayObjectSorter($unsortedarray,$totalMarks,'desc');

« previous php.notes (#188573) next »