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 $elKey => $elArray ) { > $tmpArray[$elArray['quantity']] = $elKey; > > } > > if( ksort( $tmpArray )) { > $sortedArray = array(); > foreach( $tmpArray as $elKey ) { > $sortedArray[$elKey] = $origArray[$elKey]; > > } > echo 'Original: <pre>' . print_r( $origArray, TRUE ) '</pre><br>'; > echo 'Sorted: <pre>' . print_r( $sortedArray, TRUE ) '</pre>'; > > } else { > echo 'Sorry, couldn\'t sort'; > > } this won't work if he has the same quantity for several keys, I think greets Zoltán Németh > > thnx, > Chris > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php