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 ? 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] 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 ! Link to comment https://forums.phpfreaks.com/topic/7771-solved-sorting-by-key/#findComment-28393 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.