public static void quiteSort(int[] a, int low, int high) {
if (low > high) {
return;
}
int privot = parttion(a, low, high);
quiteSort(a, low, privot - 1);
quiteSort(a, privot + 1, high);
}
private static int parttion(int[] a, int low, int high) {
// 已经排序区和未排序区,首先以最后一个元素未枢纽
int privotValue = a[high];
int i = low;
for (int j = i; j <= high - 1; j++) {
if (a[j] < privotValue) {
int temp = a[j];
a[j] = a[i];
a[i] = temp;
i++;
}
}
// 最后一个元素和中枢对换
int tem = a[high];
a[high] = a[i];
a[i] = tem;
return i;
}