Here you can find the source of shuffle()
Array.prototype.shuffle = function () { var i = this.length, j, temp; if ( i === 0 ) return false; while ( --i ) { j = Math.floor( Math.random() * ( i + 1 ) ); temp = this[i];/*from w ww . j a va 2 s. c om*/ this[i] = this[j]; this[j] = temp; } }
Array.prototype.shuffle = function() { var size = this.length; for (var i = 0; i < size; i++) { var j = Math.floor(Math.random() * size); if (i !== j) { var tmp = this[i]; this[i] = this[j]; this[j] = tmp; };
Array.prototype.shuffle = function() { var i = this.length, j, tempi, tempj; if ( i == 0 ) return false; while ( --i ) { j = Math.floor( Math.random() * ( i + 1 ) ); tempi = this[i]; tempj = this[j]; this[i] = tempj; this[j] = tempi; ...
Array.prototype.shuffle=function() { this.sort(function() { return Math.random()-0.5;}); }; Array.prototype.remove = function(from, to) { var array=this; var rest = array.slice((to || from) + 1 || array.length); array.length = from < 0 ? array.length + from : from; return array.push.apply(array, rest); }; ...
Array.prototype.shuffle = function() { var currentIndex = this.length, temporaryValue, randomIndex; while (0 !== currentIndex) { randomIndex = Math.floor(Math.random() * currentIndex); currentIndex -= 1; temporaryValue = this[currentIndex]; this[currentIndex] = this[randomIndex]; this[randomIndex] = temporaryValue; return this;
Array.prototype.shuffle = function (){ for(var j, x, i = this.length; i; j = Math.floor(Math.random() * i), x = this[--i], this[i] = this[j], this[j] = x); return this; }; String.prototype.hashCode = function(){ var hash = 5381; for (i = 0; i < this.length; i++) { char = this.charCodeAt(i); hash = ((hash<<5)+hash) + char; ...
Array.prototype.shuffle = function() { var i = this.length, j, tempi, tempj; if ( i == 0 ) return false; while ( --i ) { j = Math.floor( Math.random() * ( i + 1 ) ); tempi = this[i]; tempj = this[j]; this[i] = tempj; this[j] = tempi; ...
Array.prototype.shuffle = function() { var currentIndex = this.length, temporaryValue, randomIndex; while (0 !== currentIndex) { randomIndex = Math.floor(Math.random() * currentIndex); currentIndex -= 1; temporaryValue = this[currentIndex]; this[currentIndex] = this[randomIndex]; this[randomIndex] = temporaryValue; return this;
Array.prototype.shuffle = function() { var s = []; while (this.length) s.push(this.splice(Math.random() * this.length, 1)); while (s.length) this.push(s.pop()); return this;
var binarySearch = function(needle, haystack) { var low = 0, high = haystack.length - 1; haystack.sort(function(x, y) { return x - y; }); while (low <= high) { var middle = Math.floor((low + high) / 2); if (needle === haystack[middle]) ...