Skip to content

Instantly share code, notes, and snippets.

@kamicane
Created June 20, 2009 02:59

Revisions

  1. kamicane created this gist Jun 20, 2009.
    17 changes: 17 additions & 0 deletions Array.Shuffle.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    // Array shuffle for MooTools

    Array.implement({

    shuffle: function(){
    var i = this.length;
    if (i == 0) return;
    while (--i){
    var j = Math.floor(Math.random() * ( i + 1 ));
    var tempi = this[i];
    var tempj = this[j];
    this[i] = tempj;
    this[j] = tempi;
    }
    }

    });