[PHP] sorting multi array

2007-04-25 Thread Jon Bennett
hi, I have the following array, which I need to sort by quantity... Array ( [2408] = Array ( [name] = Havaianas Top Pink Crystal [size] = 5 (37/38) [quantity] = 4 ) [3388] = Array ( [name] = Havaianas Brazil Silver

Re: [PHP] sorting multi array

2007-04-25 Thread Frank Arensmeier
Jon, I would suggest that you should have a look at the function array_multisort. See the manual for details on what this function is capable of. //frank 25 apr 2007 kl. 01.58 skrev Jon Bennett: hi, I have the following array, which I need to sort by quantity... Array ( [2408] = Array

RE: [PHP] sorting multi array

2007-04-25 Thread Chris Boget
I have the following array, which I need to sort by quantity... I need to keep the indexes if poss. This may not be the most elegant solution. Let's call your array $origArray $tmpArray = array(); foreach( $origArray as $elKey = $elArray ) { $tmpArray[$elArray['quantity']] = $elKey; } if(

RE: [PHP] sorting multi array

2007-04-25 Thread Zoltán Németh
2007. 04. 25, szerda keltezéssel 11.39-kor Chris Boget ezt írta: I have the following array, which I need to sort by quantity... I need to keep the indexes if poss. This may not be the most elegant solution. Let's call your array $origArray $tmpArray = array(); foreach( $origArray as

Re: [PHP] sorting multi array

2007-04-25 Thread Chris Boget
this won't work if he has the same quantity for several keys, I think Yes, you are correct. If that is the case, then you would just need to change the following line $tmpArray[$elArray['quantity']] = $elKey; to $tmpArray[$elArray['quantity']][] = $elKey; then change logic in this loop:

Re: [PHP] sorting multi array

2007-04-25 Thread [EMAIL PROTECTED]
array_multisort accepts column arrays but here you try to sort row based arrays. try this: ? class ArrayUtility { /* Sorts an array by a member */ static private $sortMember; static function sortByMember($array, $member) { self::$sortMember = $member;

Re: [PHP] sorting multi array

2007-04-25 Thread Myron Turner
Jon Bennett wrote: hi, I have the following array, which I need to sort by quantity... Array ( [2408] = Array ( [name] = Havaianas Top Pink Crystal [size] = 5 (37/38) [quantity] = 4 ) [3388] = Array ( [name] = Havaianas

Re: [PHP] sorting multi array

2007-04-25 Thread Richard Lynch
Search the archives for multisort array and you should find this thread a few thousand times... On Tue, April 24, 2007 6:58 pm, Jon Bennett wrote: hi, I have the following array, which I need to sort by quantity... Array ( [2408] = Array ( [name] = Havaianas Top

[PHP] sorting multi-array

2003-07-24 Thread Ji Nmec
hello, i have got a problem, tehere is an array: $x = array( array(15,55,array(1,2,3),3,5,array(1,2,5)), array(25,55,array(1,2,3),3,5,array(1,2,5)), array(5,55,array(1,2,3),3,5,array(1,2,5)) ); and I need to sort this arraybz first item of sub-arrays (x[0][0], $x[1][0], $x[2][0]).

Re: [PHP] sorting multi-array

2003-07-24 Thread Marek Kilimajer
www.php.net/usort - slight modification of the example (hint: add [0] to $a and $b). Ji Nmec wrote: hello, i have got a problem, tehere is an array: $x = array( array(15,55,array(1,2,3),3,5,array(1,2,5)), array(25,55,array(1,2,3),3,5,array(1,2,5)),