JS array shuffle using prototype
by Prabakaran[ Edit ] 2012-07-30 14:31:22
<script type="text/javascript">
Array.prototype.shuffle = function() {
var s = [];
while (this.length) s.push(this.splice(Math.random() * this.length, 1)[0]);
while (s.length) this.push(s.pop());
return this;
}
var myary = [1,2,3,4];
myary.shuffle();
alert(myary)
</script>