let arr = [2,3,5,4,7,9,8,1,1]
for(let i = 0; i < 20; i++) {
arr[i] = Math.trunc(Math.random() * 100)
}
function quickSort(arr, left, right) {
if(left < right) {
let i = left;
let j = right;
while(i < j) {
while(i < j && arr[left] <= arr[j]) {
j--;
}
while(i < j && arr[left] >= arr[i]) {
i++;
}
if(i < j) {
let temp = arr[i];
arr[i] = arr[j];
arr[j] = temp;
}
if(i == j) {
let temp = arr[left];
arr[left] = arr[i];
arr[i] = temp;
quickSort(arr, left, i - 1);
quickSort(arr, i + 1, right);
}
}
}
}
quickSort(arr, 0, arr.length - 1)
console.log(arr)
console