I have written the Java code below after reading up on quick sort. There are no errors when running the code but the quick sort does not sort the array. It just returns the original unsorted array. I appreciate any leads.
public class quickSort {
public void quickSort(int array[], int low, int high){
if(low<high){
int pivot=partition(array, low, high);
quickSort(array, low, pivot-1);
quickSort(array, pivot+1, high);
}
}
private int partition(int array[], int low, int high){
int pivot=array[high];
int i=low-1;
for (int j = low; j < high; j++) {
if(array[j]<pivot){
i++;
swap(array[i], array[j]);
}
}
swap(array[i+1], array[high]);
return i+1;
}
private void swap(int a , int b){
int temp=a;
a=b;
b=temp;
}
public static void main(String[] args){
int a[]={4,6,3,7,9,0};
quickSort q=new quickSort();
q.quickSort(a, 0, a.length-1);
for(int i=0;i<a.length;i++){
System.out.print(a[i]+" ");
}
}
}