note 19545 added to function.asort

From: Date: Sat, 02 Mar 2002 22:42:22 +0000
Subject: note 19545 added to function.asort
Groups: php.notes 
Request: Send a blank email to php-notes+get-27282@lists.php.net to get a copy of this message
Here's my version of sorting multi-dimensional array by 2nd index. Feel free to change the code to suit your needs. function aSortBySecondIndex($multiArray, $secondIndex) { while (list($firstIndex, ) = each($multiArray)) $indexMap[$firstIndex] = $multiArray[$firstIndex][$secondIndex]; asort($indexMap); while (list($firstIndex, ) = each($indexMap)) if (is_numeric($firstIndex)) $sortedArray[] = $multiArray[$firstIndex]; else $sortedArray[$firstIndex] = $multiArray[$firstIndex]; return $sortedArray; } -- http://www.php.net/manual/en/function.asort.php http://master.php.net/manage/user-notes.php?action=edit+19545 http://master.php.net/manage/user-notes.php?action=delete+19545 http://master.php.net/manage/user-notes.php?action=reject+19545

« previous php.notes (#27282) next »