public static void main(String[] args) {
int[] arr = {1,4,7,2,5,8,3,6,9};
quickSort(arr);
}
public static void quickSort(int[] a) {
quickSort(a, 0, a.length - 1);
}
private static void quickSort(int[] a, int start, int end) {
int left = start;
int right = end - 1;
int pivot = a[end];
while (left < right) {
if (a[left] <= pivot) {
left++;
continue;
}
if (a[right] > pivot) {
right--;
continue;
}
swap(a, left++, right);
}
if (a[left] < pivot) {
left++;
}
swap(a, left, end);
if(left - 1 > start) {
quickSort(a, start, left - 1);
}
if(left + 1 < end) {
quickSort(a, left + 1, end);
}
}