Bastien Koert On 2012-04-11, at 2:18 PM, Floyd Resler <fresler@xxxxxxxxxxxxx> wrote: > > On Apr 11, 2012, at 1:11 PM, admin wrote: > >> >> >> -----Original Message----- >> From: Floyd Resler [mailto:fresler@xxxxxxxxxxxxx] >> Sent: Wednesday, April 11, 2012 11:26 AM >> To: PHP >> Subject: Sorting Help >> >> I need to sort the following array: >> { >> [Smith, Bob]=>array(137.5,125.5), >> [Jones, Robert]=>array(132.7,128.2) >> } >> >> The array needs to be sorted by the first number (i.e. 137.5) and then the >> second in descending order. I looked at array_multisort but couldn't figure >> out how to make work for my needs. >> >> Thanks! >> Floyd >> >> >> >> Here is what I did to your array >> >> $test = array("Smith, Bob"=>array(137.5,125.5),"Jones >> Robert"=>array(132.7,128.2)); >> asort($test); >> print_r('<pre>'); >> print_r($test); >> >> > > That almost worked. I did an arsort() and got the following: > Array > ( > [Guy, Matt] => Array > ( > [0] => 164.67 > [1] => 135.67 > ) > > [Smith, Toby] => Array > ( > [0] => 159.33 > [1] => 132.33 > ) > > [Young, Matt] => Array > ( > [0] => 157.67 > [1] => 131.67 > ) > > [Shobe, Dale ] => Array > ( > [0] => 157.67 > [1] => 128.67 > ) > > [King, Derrick] => Array > ( > [0] => 155.67 > [1] => 126.67 > ) > > [Reynolds, Jeff] => Array > ( > [0] => 155.67 > [1] => 133.67 > ) > > [Bobo, Tom] => Array > ( > [0] => 152.33 > [1] => 124.33 > ) > > [Henderson, Cody] => Array > ( > [0] => 150.33 > [1] => 121.33 > ) > > [McGuffin, Jimmy] => Array > ( > [0] => 145.67 > [1] => 118.67 > ) > > [Stone, Richard] => Array > ( > [0] => 145 > [1] => 119.00 > ) > > [Biggerstaff, David ] => Array > ( > [0] => 142.33 > [1] => 115.33 > ) > > [Dennis, Daymon] => Array > ( > [0] => 142 > [1] => 114.00 > ) > > [Bush, Duke] => Array > ( > [0] => 141 > [1] => 121.00 > ) > } > > That's not the entire array but it sorts just fine except for two entries. For some reason these two aren't sorting in descending order of the second element: > [King, Derrick] => Array > ( > [0] => 155.67 > [1] => 126.67 > ) > > [Reynolds, Jeff] => Array > ( > [0] => 155.67 > [1] => 133.67 > ) > Everything else sorts just fine. I'm not sure why that is. > > Thanks! > Floyd > Check that you don't have a space in front of those values. That could cause some confusion. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php