quicksort(keys, counts, i+1, right);
}
public static void quicksortWithStack(short[] keys, int[] counts, int left, int right) {
if (right <= left) return;
StackOfInts lStack = new StackOfInts(), rStack = new StackOfInts();
lStack.push(left);
rStack.push(right);
while(!lStack.isEmpty()){
left = lStack.pop();
right = rStack.pop();
int i = partition(keys, counts, left, right);
if (i-1 > left){
lStack.push(left);
rStack.push(i-1);
}
if(right > i+1){
lStack.push(i+1);
rStack.push(right);
}
}
}