Randomizing the Elements of an Array : Sort : Array Flash / Flex / ActionScript examples


Flash / Flex / ActionScript examples » Array » Sort »

 

Randomizing the Elements of an Array


 


package{
  import flash.display.Sprite;
  
  public class Main extends Sprite{
    public function Main(){

        function randomSort(elementA:Object, elementB:Object):Number {
            return Math.random(  ) .5
        
        
        var numbers:Array = new Array(  );
        for(var i:int=0;i<20;i++) {
            numbers[i= i;
        }
        numbers.sort(randomSort);
        for(var i:int=0;i<numbers.length;i++) {
            trace(numbers[i]);
        }
        
    }
  }
}

        



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


Flash / Flex / ActionScript examples

 Navioo Array
» Sort