Ask a Question related to PHP Development, Design and Development.
-
Denis -esp2008- #1
Sort a 2D array
Hello,
I have a 2D array which I would like to sort. I take
a simple example:
$tab[0][0] = 'toto';$tab[0][1] = 'toto';
$tab[1][0] = 'aaaa';$tab[1][1] = 'titi';
$tab[2][0] = 'aaaa';$tab[2][1] = 'toto';
I would like after the sort :
$tab[0][0] = 'aaaa';$tab[0][1] = 'toto';
$tab[1][0] = 'aaaa';$tab[1][1] = 'titi';
$tab[2][0] = 'toto';$tab[2][1] = 'toto';
I tried to use the usort function, but I'm not able to have the result I hope.
(I'm sorry if you don't understand my english)
Can you help me ?
Thanks,
--
Denis
Denis -esp2008- Guest
-
Sort Array in datagrid
How do you sort an array in your datagrid? I always want to be able to sort my array by an instance number. If you add a new instance I want it to... -
Sort Array
Hi Can anyone give me a pointer on sorting this array below #curr.getRateCurrencyCode()# (lowest to highest values) <cfloop from ='1' to... -
sort array by key
Hi, What I want is simple, but I can't figure it out at the moment. Let's say this is an array names $matches: Array ( => Array ( -
sort w/o using an array
I am trying to figure out if there is a way to do a sort that doesn't involve putting an entire file in memory. This kind of thing is available in... -
Help me sort a two - d array
I need help sorting a multidimensional array. I have an array myarray(column_no, row_no) it has 5 columns for this example I have used 4 rows... -
Denis -esp2008- #2
Re: Sort a 2D array
Bad example.
My problem is:
$tab[0][0] = 'to';$tab[0][1] = 'BB';$tab[0][2] = 'XX';
$tab[1][0] = 'aa';$tab[1][1] = 'AA';$tab[0][2] = 'ZZ';
$tab[2][0] = 'aa';$tab[2][1] = 'CC';$tab[0][2] = 'YY';
I would like after the sort :
$tab[0][0] == 'aa';$tab[0][1] == 'CC';$tab[0][1] == 'YY';
$tab[1][0] == 'aa';$tab[0][1] == 'AA';$tab[1][1] == 'ZZ';
$tab[2][0] == 'to';$tab[0][1] == 'BB';$tab[2][1] == 'XX';
(sorting by line[0] and line[2])
Thanks,
--
Denis
Denis -esp2008- Guest



Reply With Quote

