1 Reply Latest reply on Jun 7, 2006 5:13 AM by DazFaz

# arrange the teams by points

I have to do finish this today, so urgent help please.

The team1 to team4 will score point like this

team1_mc.point = 100;
team2_mc.point = 90;
team3_mc.point = 120;
team4_mc.point = 70;

when the teams score what I need is arrange like this (if teams score like above) .

plase1 = team3;
plase2 = team1
plase3 = team2
plase4 = team4

• ###### 1. Re: arrange the teams by points
team1_mc = 100;
team2_mc = 90;
team3_mc = 120;
team4_mc = 70;
trace("team1_mc = "+team1_mc);
trace("team2_mc = "+team2_mc);
trace("team3_mc = "+team3_mc);
trace("team4_mc = "+team4_mc);

var team_mc:Array = new Array ();
team_mc.push ({points:team1_mc});
team_mc.push ({points:team2_mc});
team_mc.push ({points:team3_mc});
team_mc.push ({points:team4_mc});
trace ("-----Highest first-----");
team_mc.sortOn ("points", Array.DESCENDING | Array.NUMERIC);
for (var i:Number = 0; i < team_mc.length; i++) {
trace (team_mc .points);
this["team"+(i+1)+"_mc"] = team_mc
.points
}
trace("team1_mc = "+team1_mc);
trace("team2_mc = "+team2_mc);
trace("team3_mc = "+team3_mc);
trace("team4_mc = "+team4_mc);

trace ("-----Lowest first-----");
team_mc.sortOn ("points", Array.NUMERIC);
for (var i:Number = 0; i < team_mc.length; i++) {
trace (team_mc .points);
this["team"+(i+1)+"_mc"] = team_mc
.points
}
trace("team1_mc = "+team1_mc);
trace("team2_mc = "+team2_mc);
trace("team3_mc = "+team3_mc);
trace("team4_mc = "+team4_mc);

I hope this helps

Cheers