I am trying to use a dual-pivot quickSort algorithm to make a list of numbers from a text file sort in descending order. I currently have it in ascending and can't figure out how to switch it. Below is the code to get it to sort ascending. I think it is just a sign somewhere but i'm not sure where.
private void quickSort(int[] A, int left, int right){
int temp;
if(right-left>=1){
int lp = A[left];
int rp = A[right];
if(lp>rp){
temp = lp;
lp = rp;
rp = temp;
temp = A[left];
A[left] = A[right];
A[right] = temp;
}
int l = left+1;
int g = right-1;
int k = l;
while(k<=g){
if(A[k]<lp){
temp = A[k];
A[k] = A[l];
A[l] = temp;
l++;
}
else{
if(A[k]>rp){
while(A[g]>lp && k<g)
g--;
temp = A[k];
A[k]= A[g];
A[g] = temp;
g--;
if(A[k]<lp){
temp = A[k];
A[k] = A[l];
A[l] = temp;
l++;
}
}
}
k++;
}
l--;
g++;
temp = A[left];
A[left] = A[l];
A[l] = temp;
temp = A[right];
A[right] = A[g];
A[g] = temp;
quickSort(A,left,l-1);
quickSort(A,l+1,g-1);
quickSort(A,g+1,right);
}
}