acey99 Posted April 18, 2006 Share Posted April 18, 2006 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 ? Quote Link to comment https://forums.phpfreaks.com/topic/7771-solved-sorting-by-key/ Share on other sites More sharing options...
Barand Posted April 18, 2006 Share Posted April 18, 2006 [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 resultsecho '<pre>', print_r ($StandingsData, true), '</pre>';[/code] Quote Link to comment https://forums.phpfreaks.com/topic/7771-solved-sorting-by-key/#findComment-28368 Share on other sites More sharing options...
acey99 Posted April 18, 2006 Author Share Posted April 18, 2006 Thanks ! Quote Link to comment https://forums.phpfreaks.com/topic/7771-solved-sorting-by-key/#findComment-28393 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.