const _quickSort = (array) => {
myQuickSort(array, 0, array.length - 1);
return array;
};
function myQuickSort(array, l, r) {
if (l < r) {
let index = partition(array, l, r);
myQuickSort(array, l, index - 1);
myQuickSort(array, index + 1, r);
}
}
function partition(array, l, r) {
let pivot = array[Math.floor(Math.random() * (r - l + 1)) + l];
while (l < r) {
while (array[l] < pivot) l++;
while (array[r] > pivot) r--;
if (l !== r && array[l] === array[r]) l++;
else if (l < r) {
[array[l], array[r]] = [array[r], array[l]];
}
}
return l;
}