import java.util.Arrays;
public class Main {
public static void main(String[] args) {
int[] arr={1,8,4,7,5,2,0,-8,-21};
quickSort(arr,0,arr.length-1);
System.out.println(Arrays.toString(arr));
}
public static void quickSort(int[] arr,int left,int right){
if(left>right){
return;
}
int base=arr[left];
int i=left;
int j=right;
while(i!=j){
while(arr[j]>=base && i<j){
j--;
}
while(arr[i]<=base && i<j){
i++;
}
int temp=arr[j];
arr[j]=arr[i];
arr[i]=temp;
}
arr[left]=arr[i];
arr[i]=base;
quickSort(arr,left,i-1);
quickSort(arr,i+1,right);
}
}