package algorithms;

public class MergeSort {
    public static <T extends Object & Comparable<T>> void sort(T[] array) {
        T[] aux = (T[]) new Object[array.length];
        for (int i = 0; i < array.length; i++) {
            aux[i] = array[i];
        }
        sort(array, 0, array.length - 1, aux);
    }

    private static <T extends Object & Comparable<T>> void sort(T[] array, int lo, int hi, T[] aux) {
        if (lo >= hi) {
            return;
        }
        int mid = (lo + hi) / 2;
        sort(aux, lo, mid, array);
        sort(aux, mid + 1, hi, array);
        merge(array, lo, mid, hi, aux);
    }

    @SuppressWarnings("unchecked")
    static <T extends Object & Comparable<T>> void merge(T[] array, int lo, int mid, int hi,
                                                         T[] aux) {
        int idx = lo;
        int lo1 = lo;
        int hi1 = mid;
        int lo2 = mid + 1;
        int hi2 = hi;
        while (lo1 <= hi1 && lo2 <= hi2) {
            if (aux[lo1].compareTo((T) aux[lo2]) < 0) {
                array[idx++] = (T) aux[lo1++];
            } else {
                array[idx++] = (T) aux[lo2++];
            }
        }
        while (lo1 <= hi1) {
            array[idx++] = (T) aux[lo1++];
        }
        while (lo2 <= hi2) {
            array[idx++] = (T) aux[lo2++];
        }
    }
}

@@ -1009,20 +1009,16 @@
 mpareTo(
-(T) 
 aux%5Blo2%5D
@@ -1048,36 +1048,32 @@
   array%5Bidx++%5D =
- (T)
  aux%5Blo1++%5D;%0A   
@@ -1112,36 +1112,32 @@
   array%5Bidx++%5D =
- (T)
  aux%5Blo2++%5D;%0A   
@@ -1208,28 +1208,24 @@
 ray%5Bidx++%5D =
- (T)
  aux%5Blo1++%5D;
@@ -1294,12 +1294,8 @@
 +%5D =
- (T)
  aux

Update merge sort