Not yet rated

Problem

You need to randomize an array

Solution

Use the function below.

Detailed explanation

function randomizeArray(array:Array):Array{

var newArray:Array = new Array();

while(array.length > 0){

newArray.push(array.splice(Math.floor(Math.random()*array.length), 1));

}

return newArray;

}

+
This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License. Permissions beyond the scope of this license, pertaining to the examples of code included within this work are available at Adobe.

Report abuse

Related recipes