Here you can find the source of validate_sorted()
/**/*from w w w . j a v a 2 s. c om*/ * function validates array if it is sorted */ Array.prototype.validate_sorted = function(){ for (var i = 0; i < this.length - 1; i++){ if (this[i] > this[i+1]) return false; } return true; };
Array.prototype.propSort = function propSort(prop) { return this.sort(function(a, b) { return +a[prop] - +b[prop]; }); }; Array.prototype.propAsort = function propSort(prop) { return this.sort(function(a, b) { return +b[prop] - +a[prop]; }); };
Array.prototype.sleepSort = function () { var _arr = []; this.forEach(function (number) { setTimeout(function () { _arr.push(number); }, 2 * number); }); return _arr;
Array.prototype.stableSort = function(f) { return this.map((ele, i) => ({ele: ele, i: i})) .sort((a, b) => { var val = f(a.ele, b.ele); if (val === 0) { return a.i - b.i; return val; }).map(ele => { ...
Array.prototype.superSort = function() { function dynamicSort(property) { return function (obj1,obj2) { return obj1[property] > obj2[property] ? 1 : obj1[property] < obj2[property] ? -1 : 0; var props = arguments; return this.sort(function (obj1, obj2) { ...
Array.prototype.timeoutSort = function (f) { this.forEach(function (n) { setTimeout(function () { f(n) }, 5 * n) });
Array.prototype.qsort = function (left, right) { var pivot, newPivot, pivotVal, tmp; if (left === undefined) { left = 0; right = this.length - 1; if (left < right) { pivot = left + Math.ceil((right - left) / 2); pivotVal = this[pivot]; ...