Hello :)
you must creates benchs to test all solutions but the first is the sort()
method with a custom method
var myArray:Array = [
[20,40],
[20,10],
[30,15],
[30,35],
[40,100],
[1000,1]
];
var compare:Function = function ( a , b )
{
if ( a[1] < b[1] )
{
return -1 ;
}
else if (a[1] > b[1] )
{
return 1 ;
}
else
{
return 0 ;
}
}
trace(myArray) ;
myArray.sort( compare ) ;
trace(myArray) ;
I think the Actionscript in FP8 or FP9 really speed !
EKA+ :)
2007/2/1, [EMAIL PROTECTED] <[EMAIL PROTECTED]>:
Hello,
Can anybody tell me how to sort the following array based upon the second
value
within each array item
myArray:Array = [ [20,40],[20,10],[30,15],[30,35],[40,100],[1000,1]];
this should be something like
[[1000,1], [20,10], .....
Faster the better cos its for a game and gets called a lot of times.
regards
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com