public class Array{
public static void quicksort(int []list){
sort(list,0,list.length-1);
}
public static void sort(int []list,int low,int high){
int pivot=low;
int left=low;
int right=high;
while(left<right){
while(list[left]<list[pivot]&&left<right){//find left value bigger than pivot and left < right
left++;
}
exchange(list,left,pivot);//swap left value and pivot
pivot=left;
while(list[pivot]<list[right]&&left<right){//find right value smaller than pivot and left < right
right--;
}
exchange(list,right,pivot);//swap right value and pivot
pivot=right;
}
if(left<high){//recusion for left side
sort(list,left+1,high);
}
if(right>low){//recusion for right side
sort(list,low,right-1);
}
}
public static void exchange(int []list,int i, int j){
int temp=list[i];
list[i]=list[j];
list[j]=temp;
}
}