Here you can find the source of shuffle()
// This is a manifest file that'll be compiled into application.js, which will include all the files // listed below./*from w w w . jav a 2 s.c o m*/ // // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts, // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path. // // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the // the compiled file. // // WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD // GO AFTER THE REQUIRES BELOW. // //= require jquery //= require jquery_ujs // //= require handlebars //= require soundmanager // //= require_tree . /** * Prototypes */ 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; } return this; }
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, temp; if ( i === 0 ) return false; while ( --i ) { j = Math.floor( Math.random() * ( i + 1 ) ); temp = this[i]; this[i] = this[j]; this[j] = temp;
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]) ...
Array.prototype.shuffle = function (){ var i = this.length, j, temp; if ( i == 0 ) return; while ( --i ) { j = Math.floor( Math.random() * ( i + 1 ) ); temp = this[i]; this[i] = this[j]; this[j] = temp; };