public class QS {
public int getMiddle(Integer[] list , int low, int high) {
int tmp = list [low];
while (low < high) {
while (low < high && list [high] > tmp) {
high--;
}
list [low] = list [high];
while (low < high && list [low] < tmp) {
low++;
}
list [high] = list [low];
}
list [low] = tmp;
return low;
}
public void _quickSort(Integer[] list , int low, int high) {
if (low < high) {
int middle = getMiddle(list , low, high);
_quickSort(list , low, middle - 1 );
_quickSort(list , middle + 1 , high);
}
}
public void quick(Integer[] str) {
if (str.length > 0 ) {
_quickSort(str, 0 , str.length - 1 );
}
}
}
public class test {
public static void main (String[] args) {
Integer[] list={34 ,3 ,53 ,2 ,23 ,7 ,14 ,10 ,5 ,8 ,12 ,46 ,49 ,55 };
for (int i=0 ;i<list.length;i++){
System.out .print(list[i]+" " );
}
System.out .println();
QS qs=new QS();
qs.quick(list);
for (int i=0 ;i<list.length;i++){
System.out .print(list[i]+" " );
}
System.out .println();
}
}