Hi all
I am trying to create a leaderboard for a game I am creating and would apprediate a little help on trying to create a leaderboard for the scoring. My code is as follows:
function arraySort() {
var a1:Array = new Array(“team a”,“team b”,“team c”,“team d”,“team e”);
var a2:Array = new Array(10,5,10,5,6);
var a3:Array = new Array();
var mapArray:Array = new Array();
for (var i:Number = 0; i < a1.length; i++) {
mapArray* = new Object( { val1: a1*, val2: Number(a2*) } );
}
mapArray.sortOn(“val2”, Array.DESCENDING | Array.NUMERIC);
for (var i:Number = 0; i < a1.length; i++) {
a3* = mapArray*.val1;
mapArray*.val1._y = yList*;
}
}
So this sorts the a1 array according to the a2 numeric array. the problem I am getting is that if there is duplication in the scoring (a2 array), say ‘team a’ has 10 points, as does ‘team c’… ‘team c’ is going to the top of the leaderboard whereas it should be ‘team a’ because alphabetically it should be higher. Could anybody suggest how I can adapt my code?
Cheers