If this has been answered before I apologize (I haven't seen to found it). I have a game pool website that wishes to sort by points (pts). In the below example I want 'Team B' to be first as their points are higher then Team A's at 22 compared to 12. While the solution on this page (How to sort an array of associative arrays by value of a given key in PHP?) seemed to be very similar to what I was looking for I wasn't able to get it to work.
Array
(
[0] => Team Object
(
[id] => 5
[name] => Team A
[games_played] => 13
[wins] => 6
[losses] => 7
[ot_losses] => 0
[pts] => 12
[goals_for] => 7.5
[goals_against] => 22
[streak] => 6-7
)
[1] => Team Object
(
[id] => 2
[name] => Team B
[games_played] => 13
[wins] => 11
[losses] => 2
[ot_losses] => 0
[pts] => 22
[goals_for] => 51
[goals_against] => 19
[streak] => 11-2
)
I suspect I'm on the right path with the following but missing something...
$new_array = array();
foreach ($array_objects as $key => $row)
{
$new_array[$key] = $row['pts'];
}
array_multisort($price, SORT_DESC, $array_objects);