johnsmith153 Posted September 5, 2008 Share Posted September 5, 2008 I need to sort in order based on Score A and Score B Score A is most important, but if Score A is tied, then Score B decides their position. $Name = array(); $ScoreA = array(); $ScoreB = array(); $Name[]="John"; $Name[]="David"; $Name[]="Ben"; $Name[]="Steve"; $ScoreA[]="6"; $ScoreA[]="6"; $ScoreA[]="3"; $ScoreA[]="9"; $ScoreB[]="7"; $ScoreB[]="4"; $ScoreB[]="3"; $ScoreB[]="2"; array_multisort($ScoreA,SORT_NUMERIC,SORT_DESC, $ScoreB,SORT_NUMERIC,SORT_DESC); foreach($Name as $valuetoshow){echo $valuetoshow."<br>";} //should return: //Steve //John //David //Ben //BUT DOESN'T What have I done wrong? Link to comment https://forums.phpfreaks.com/topic/122894-simple-array-help/ Share on other sites More sharing options...
johnsmith153 Posted September 5, 2008 Author Share Posted September 5, 2008 array_multisort($ScoreA,SORT_NUMERIC,SORT_DESC, $ScoreB,SORT_NUMERIC,SORT_DESC, $Name,SORT_ASC);foreach($Name as $valuetoshow){echo $valuetoshow."<br>";} You missed off "$Name,SORT_ASC" so it only sorted the two arrays Link to comment https://forums.phpfreaks.com/topic/122894-simple-array-help/#findComment-634734 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.