@@ -0,0 +1,1284 @@
+package com.algorithms.sorting;%0A%0A%0Apublic class Merge %7B%0A%0A    private static void sort(Comparable%5B%5D a, Comparable%5B%5D aux, int lo, int hi) %7B%0A        if (lo %3E= hi) return;%0A%0A        int mid = (lo + hi) / 2;%0A        sort(a, aux, lo, mid);%0A        sort(a, aux, mid + 1, hi);%0A        merge(a, aux, lo, mid, hi);%0A    %7D%0A%0A    public static void sort(Comparable%5B%5D a) %7B%0A        Comparable%5B%5D aux = new Comparable%5Ba.length%5D;%0A        sort(a, aux, 0, a.length - 1)%0A    %7D%0A%0A    private static boolean less(Comparable v, Comparable w) %7B%0A        return v.compareTo(w) %3C 0;%0A    %7D%0A%0A    public static void merge(Comparable%5B%5D a, Comparable%5B%5D aux, int lo, int mid, int hi) %7B%0A        assert isSorted(a, lo, mid);%0A        assert isSorted(a, mid+1, hi);%0A%0A        for (int i = lo; i %3C hi; i++) aux%5Bi%5D = a%5Bi%5D;%0A%0A        int i = lo, j = mid + 1;%0A        for (int k = lo; k %3C hi; k ++) %7B%0A            if (i %3E mid) a%5Bk%5D = aux%5Bj++%5D;%0A            else if (j %3E hi) a%5Bk%5D = aux%5Bi++%5D;%0A            if (less(aux%5Bj%5D, aux%5Bi%5D)) a%5Bk%5D = aux%5Bj++%5D;%0A            else a%5Bk%5D = aux%5Bi++%5D;%0A        %7D%0A%0A        assert isSorted(a, lo, hi);%0A    %7D%0A%0A    private static boolean isSorted(Comparable%5B%5D a, int lo, int hi) %7B%0A        for (int i = lo; i %3C hi; i ++) %7B%0A            if (less(a%5Bi+1%5D, a%5Bi%5D)) return false;%0A        %7D%0A        return true;%0A    %7D%0A%7D%0A

Create code for Merge-sort