function QuickSort(R, lo, hi) {
var i = lo, j = hi;
var temp;
if (i < j) {
temp = R[i];
while (i != j) {
while (j > i && R[j] >= temp) { --j; }
R[i] = R[j];
while (j > i && R[i] <= temp) { ++i; }
R[j] = R[i];
}
R[i] = temp;
QuickSort(R, lo, i - 1);
QuickSort(R, i + 1, hi);
}
}
var arr = [3,44,38,5,47,15,36,26,27,2,46,4,19,50,48,48];
QuickSort(arr, 0, arr.length - 1);
console.log(arr);
R = [3,44,38,5,47,15,36,26,27,2,46,4,19,50,48,48];
var l = R.length - 1;
while (l--) {
for (var i = 0, j = 1; i < l + 1; i++ , j++) {
if (R[i] > R[j]) {
var temp = R[i];
R[i] = R[j];
R[j] = temp;
}
}
}
console.log(R);
R = [3,44,38,5,47,15,36,26,27,2,46,4,19,50,48,48];
l = R.length;
while (--l) {
var index = 0;
for (var i = 1; i <= l; i++) {
if (R[i] > R[index]) {
index = i;
}
}
var temp = R[l];
R[l] = R[index];
R[index] = temp;
}
console.log(R);
console