Re: Shuffle array elements (3 to end of array) in random order



Tuxedo wrote:

Thanks for the tip, which by the sound of it, I guess must be easier than
randomly reorganise only a specified segment of the complete array.

To answer myself, with some extra help from about.com
(http://javascript.about.com/library/blsort2.htm) the following solution
appears to work just fine:

function randOrd(){
return (Math.round(Math.random())-0.5);
}

var a = new Array('fourth','fifth','sixth','etc')
a.sort(randOrd)
a.unshift('first','second','third')
.



Relevant Pages