手写快速排序
public static void quicksort(int arr[], int left, int right){
int index;
if (left < right) {
index = partition(arr, left, right);
quicksort(arr, left, index - 1);
quicksort(arr, index + 1, right);
}
}
public static int partition(int arr[], int left, int right){
int key = arr[left];
while (left < right){
while (right > left&& arr[right]>= key)
right --;
if (right > left)
arr[left++] = arr[right];
while (left < right && arr[left] <= key)
left++;
if (left < right)
arr[right--] = arr[left];
}
arr[left] = key;
return left;
}