#22006 [Opn->WFx]: Multidimensional Array sorting

From: Date: Sun, 02 Feb 2003 07:06:52 +0000
Subject: #22006 [Opn->WFx]: Multidimensional Array sorting
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-31872@lists.php.net to get a copy of this message
ID: 22006 Updated by: pollita@php.net Reported By: php@richardneill.org -Status: Open +Status: Wont fix Bug Type: Feature/Change Request Operating System: Linux PHP Version: 4.2.0 New Comment: There are many examples and user comments on the manual page for usort() which show how to accomplish this using existing functionality. http://www.php.net/manual/en/function.usort.php Previous Comments: ------------------------------------------------------------------------ [2003-02-01 23:48:23] php@richardneill.org Oops - that doesn't quite make sense. We want to be able to sort on "the 3rd column" or "the 7th row" if it's 2-D; in the case of 3-D, we need to be able to sort on "(the line determined by depth=4 and height=3)". So a better prototype would be: my_array_sort(my_array,i,j,-,l) meaning: sort by index k, where the other indices have values of i,j,l respectively) [Array multisort will work, but only to sort by column; therefore if one wants to sort by ROW, the array must be redesigned]. Sorry the first comment isn't mathematically sensible! ------------------------------------------------------------------------ [2003-02-01 23:24:16] php@richardneill.org Consider an array of arrays : myarray["$i"]["$j"]...["$n"] I'd like to see a function which will allow me to sort this on the nth array index. Something like: my_array_function(myarray, n) where n is the dimension to sort on. This would make it easy to sort any array by row, column, depth, etc Sorry if this feature already exists - I have spend 2 hours reading the manual and googling for it to no avail. I know there are ways to get around it, but a dedicated function would be nice. Thanks. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=22006&edit=1

« previous php.bugs (#31872) next »