/// 快速快速排序算法
Array.prototype.quickSort = function (left, right) {
// left = left || 0;
// right = right || this.length - 1;
if (left < right) {
var x = this[right],
i = left - 1,
temp;
for (var j = left; j <= right; j++) {
if (this[j] <= x) {
i++;
temp = this[i];
this[i] = this[j];
this[j] = temp;
}
}
this.quickSort(left, i - 1);
this.quickSort(i + 1, right);
};
}
// 搅乱当前的数组(洗牌)shuffle an array Fisher-Yates style
Array.prototype.shuffle = function () {
var i = this.length;
if (i !== 0) {
while (--i) {
var j = Math.floor(Math.random() * (i + 1));
var temp = this[i];
this[i] = this[j];
this[j] = temp;
}
}
};