Jump to content

Archived

This topic is now archived and is closed to further replies.

acey99

**solved** Sorting by key ?

Recommended Posts

ok say I have the following:


$StandingsData[$i]['teamid']
$StandingsData[$i]['gamesplayed']
$StandingsData[$i]['points']


& want to sort this by say points, how do I do that ?

Share this post


Link to post
Share on other sites

[code]function points_sort ($a, $b) {

          if ($a['points'] == $b['points']) return 0;
          return ($a['points'] < $b['points']) ? -1 : 1;
}


usort ($StandingsData, 'points_sort');


// check results

echo '<pre>', print_r ($StandingsData, true), '</pre>';[/code]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.