note 109003 added to function.usort

From: Date: Tue, 12 Jun 2012 00:19:43 +0000
Subject: note 109003 added to function.usort
Groups: php.notes 
Request: Send a blank email to php-notes+get-188533@lists.php.net to get a copy of this message
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'); ---- Server IP: 69.147.83.197 Probable Submitter: 223.223.146.160 ---- Manual Page -- http://www.php.net/manual/en/function.usort.php Edit -- https://master.php.net/note/edit/109003 Del: integrated -- https://master.php.net/note/delete/109003/integrated Del: useless -- https://master.php.net/note/delete/109003/useless Del: bad code -- https://master.php.net/note/delete/109003/bad+code Del: spam -- https://master.php.net/note/delete/109003/spam Del: non-english -- https://master.php.net/note/delete/109003/non-english Del: in docs -- https://master.php.net/note/delete/109003/in+docs Del: other reasons-- https://master.php.net/note/delete/109003 Reject -- https://master.php.net/note/reject/109003 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#188533) next »