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] => Hav

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] => Havaian

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: $b[self::$sortMember]; } } ArrayUtility::sortByMember($array, 'quantity'); ?> Am 25.04.2007, 12:36 Uhr, schrieb Frank Arensmeier <[EMAIL PROTECTED]>: Jon, I would suggest that you should have

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 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( $orig

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; } i

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] => Arr

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ří Němec 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)), array(5,55,array(1,2,3),3,5,array