Sorting Numerically: Array.NUMERIC
package{
import flash.display.Sprite;
public class Main extends Sprite{
public function Main(){
var aNumbers:Array = [10, 1, 2, 15, 21, 13, 33, 3];
aNumbers.sort();
trace(aNumbers.toString());
var aNumbers:Array = [10, 1, 2, 15, 21, 13, 33, 3];
aNumbers.sort(Array.NUMERIC);
trace(aNumbers.toString());
}
}
}
1,10,13,15,2,21,3,33
1,2,3,10,13,15,21,33
Related examples in the same category