/** non-destructive randomizer **/function shuffle(arr) { var r = arr.slice(); return r.sort(function(a,b){ return Math.random()-Math.random(); });}
/** destructive randomizer **/function shuffle(a,b){return Math.random()-Math.random();}// ... then sort in place ...someArray.sort(shuffle);
[1, 2, 3, 4, 5].sort(function() { return 0.5 - Math.random();});
var r = arr.slice();
function shuffle(arr) { var n = arr.length, t, i; while (n) { i = Math.random() * n-- | 0; // 0 ≤ i < n t = arr[n]; arr[n] = arr[i]; arr[i] = t; } return arr;}
var shuffled = Link([0, 1, 2, 3, 4]).shuffle();