MergeSort,归并排序
package _Sort.Algorithm /** * https://www.geeksforgeeks.org/merge-sort/ * https://www.cnblogs.com/chengxiao/p/6194356.html * best/worst/average Time complexity are O(nlogn), Space complexity is O(n), stable * # is Divide and Conquer algorithm * Basic idea * 1. find the middle point to divide the array into two halves; * 2. Call MergeSort for first halves; * 3. Call MergeSort for second halves; * 4. Merge two halves; * */ class MergeSort { fun sortArray(array: IntArray): IntArray { //create temp array first, avoid create temp in recursion val tempArray = IntArray(array.size) val left = 0 val