> 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';

}

thnx,
Chris

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to