}
/**
* 根据基数分组后得到基数的位置下标
* 参数会被修改。
*/
public final static int getBaseIndex(int[] array1,int start,int end) {
int baseValue = array1[start];
while (start < end) {
if (array1[end] >= baseValue) {
array1[start]=array1[end];
end--;
}else {
array1[end]=array1[start];
start++;
}
}
array1[start] = baseValue;
return start;
}
public void quickSort2(int a[]){
if(a==null||a.length<=0)return;
Stack<Integer> index=new Stack<Integer>();
int start=0;
int end=a.length-1;
int pivotPos;
index.push(start);
index.push(end);
while(!index.isEmpty()){
end=index.pop();
start=index.pop();
pivotPos=partition(a,start,end);
if(start<pivotPos-1){
index.push(start);
index.push(pivotPos-1);
}
if(end>pivotPos+1){
index.push(pivotPos+1);
index.push(end);
}
}
}