快速排序
class Solution {
public int[] sortArray(int[] nums) {
if(nums==null || nums.length==0) return nums;
quickSort(nums, 0, nums.length-1);
return nums;
}
private void quickSort(int[] nums, int start, int end) {
if(start>=end) {
return;
}
int mid=nums[(start+end)/2], left=start, right=end;
while (left<=right)
{
while (left<=right && nums[left]<mid) {
left++;
}
while (left<=right && nums[right]>mid) {
right--;
}
if(left<=right) {
int temp=nums[left];
nums[left]=nums[right];
nums[right]=temp;
left++; right--;
}
}
quickSort(nums, start, right);
quickSort(nums, left, end);
}
}