Re: Anyone ever done this - sort a multi-dimensional array
| From: | Steve Cayford | Date: | Thu, 15 Nov 2001 16:27:23 +0000 |
| Subject: | Re: Anyone ever done this - sort a multi-dimensional array | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-74734@lists.php.net to get a copy of this message | ||
You can roll your own fairly easily:
function mycmp($a,$b) {
return strcmp($a[1],$b[1]);} usort($array, 'mycmp'); ...something like that at any rate. -Steve On Thursday, November 15, 2001, at 10:07 AM, Richard S. Crawford wrote:
Of the type...$array[0][0] = "!row of c's"; $array[0][1] = "cccc"; $array[1][0] = "row of a's"; $array[1][1] = "aaaa"; $array[2][0] = "a row of b's"; $array[2][1] = "bbbb";such that you sort on the value of the y-column? In this case, it would end up as:+--------------+------+ | row of a's | aaaa | | a row of b's | bbbb | | !row of c's | cccc | +--------------+------+Strange that I've been working with PHP this long and have never come across this problem. Sliante, Richard S. Crawford http://www.mossroot.com mailto:rscrawford@mossroot.com AIM: Buffalo2K ICQ: 11646404 Y!: rscrawford "It is only with the heart that we see rightly; what is essential is invisible to the eye." --Antoine de Saint Exupéry "Push the button, Max!" -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net