快速排序算法-java
// An highlighted block
void fastSort(int[] nums, int start, int end) {
if (start >= end) {
return;
}
//基准
int p = nums[start];
//左右游标
int i = start;
int j = end;
while (i < j) {
while (i < j && nums[j] >= p) {
j --;
}
while (i < j && nums[i] <= p) {
i ++;
}
int temp = nums[i];
nums[i] = nums[j];
nums[j] = temp;
}
//交换基准点到正确的位置
nums[start] = nums[i];
nums[i] = p;
fastSort(nums, start,i - 1);
fastSort(nums,i + 1,end);
}