ah, the experiences of lists of random numbers. Javascript makes something like this super easy:
var numArr = Array(20);
for(var i = 0; i < numArr.length;i++){
numArr[i] = i;
}
numArr.sort(function(){return Math.random()-.5;});
console.log(numArr);
some outputs from the above code:
[15, 18, 10, 1, 7, 6, 9, 8, 4, 19, 11, 5, 12, 13, 14, 2, 3, 16, 17, 0]
[10, 17, 5, 15, 4, 9, 13, 1, 19, 11, 0, 12, 6, 2, 18, 14, 7, 3, 16, 8]
[19, 2, 3, 4, 5, 6, 8, 7, 13, 11, 0, 9, 1, 14, 15, 16, 17, 12, 10, 18]
the magic here is in the built-in javascript sort function. you can pass it random values and it will randomly sort all the elements.
another option that may be simpler for you (if you don't have an easy way to make sort be random) is to first initialize a new ordered array then create another array and pull from the first randomly and append to the second.
var arr = [0,1,2,3,4,5,6,7,8,9];
var endArr = [];
while(arr.length > 0){
var loc = (Math.random() * arr.length) >> 0; //bitwise operator >> 0 does a shift 0 and gives an int. Math.random() returns a value between 0 and 1.
endArr.push(arr[loc]); //add the picked element to the destination array.
arr.splice(loc,1); //remove the just added element from the source array; arr.length is now 1 less.
}
the 2nd way is probably one of the easiest ways to do what you are proposing. Have fun!