private static void mergeSort(int[] arr, int left, int rigint) {
//二分到最小粒度
if (arr == null || arr.length <= 1 || left >= rigint) {
return;
}
//求出中间索引
int mid = (rigint+left) / 2;
//继续分[left,mid]
mergeSort(arr, left, mid);
//继续分[mid+1,right]
mergeSort(arr, mid + 1, rigint);
//副本left--rignt的长度
int aux[] = new int[rigint - left + 1];
//进行copy
for (int i = left; i <= rigint; i++) {
aux[i - left] = arr[i];
}
int i = left;
int j = mid + 1;
System.out.println("arr="+JSON.toJSONString(arr));
for (int k = left; k <= rigint; k++) {
if (i>mid){
arr[k]=aux[j-left];
j++;
}else if (j>rigint){
arr[k]=aux[i-left];
i++;
}else if (aux[i-left]<aux[j-left]){
arr[k]=aux[i-left];
i++;
}else {
arr[k]=aux[j-left];
j++;
}
}
}