static IComparable[] merge(IComparable[] arr1, IComparable[] arr2) { IComparable[] outarr = new IComparable[arr1.Length + arr2.Length]; arr1.CopyTo(outarr, 0); arr2.CopyTo(outarr, arr1.Length); if(outarr.Length>1) qSort(outarr); return outarr; }
static void quickSort(IComparable[] arr,int start, int end) { IComparable[] lastarr = new IComparable[arr.Length]; arr.CopyTo(lastarr,0); int i = start, j = end; IComparable piv = arr[(i + j) / 2]; while (i <= j) { while (arr[i].CompareTo(piv)<0) i++; while (arr[j].CompareTo(piv)>0) j--; if (i <= j) swap(arr,i++,j--); } if (start < j) quickSort(arr, start, j); if (end > i) quickSort(arr, i, end); }