public class test2 {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
int[] a={3,2,5,7,9,1,3};
quicksort(a,0,a.length-1);
for (int i = 0; i < a.length; i++) {
System.out.print(a[i]+" ");
}
}
public static void quicksort(int[]arr,int low,int high) {
if (low<high) {
int a=getmiddle(arr, low, high);
quicksort(arr, low, a-1);
quicksort(arr, a+1, high);
}
}
public static int getmiddle(int[] arr,int low,int high) {
int temp=arr[low];
while (low<high) {
while (low<high &&arr[high]>=temp) {
high--;
}
arr[low]=arr[high];
while(low<high && arr[low]<=temp){
low++;
}
arr[high]=arr[low];
}
arr[low]=temp;
return low;
}
}