//http://blog.codinghorror.com/the-danger-of-naivete/
//Knuth-Fisher-Yates shuffle
function shuffle(array:Array):Array
{
var m:int = array.length;
var t:*;
var i:int;
while (m){ // While there remain elements to shuffle…
i = Math.floor(Math.random() * m--); // Pick a remaining element…
t = array[m]; // And swap it with the current element.
array[m] = array[i];
array[i] = t;
}
return array;
}
Comments
0 B
|👍
/👎
0 B
|0 👍
/0 👎
0 B
|👍
/👎
0 B
|👍
/👎