note 24080 added to function.array-multisort

From: Date: Tue, 06 Aug 2002 06:18:28 +0000
Subject: note 24080 added to function.array-multisort
Groups: php.notes 
Request: Send a blank email to php-notes+get-34382@lists.php.net to get a copy of this message
To: salim@codesplash.com Another option is to modify the SQL statement and not use the array_multisort function. MySQL supports the ORDER BY clause. For instance: //Get table sorted on field2 output into $result1 and $result2 array // ascending order by field2 $result1 = mysql_query("SELECT field1, field2 FROM table ORDER BY field2"); // descending order by field2 $result2 = mysql_query("SELECT field1, field2 FROM table ORDER BY field2 DESC"); Note: I have not benchmarking to determine whether PHP is faster in sorting or MySQL. It would be worth some investigation if you are using large tables. Hope this helps. -- http://www.php.net/manual/en/function.array-multisort.php http://master.php.net/manage/user-notes.php?action=edit+24080 http://master.php.net/manage/user-notes.php?action=delete+24080 http://master.php.net/manage/user-notes.php?action=reject+24080

« previous php.notes (#34382) next »