public static List<Element> mergeSort(List<Element> list) {
        if (list.size() <= 1) {
            return list;
        }

        // Make two arrays for range < pivot && range > pivot
        List<Element> left = new ArrayList<Element>();
        List<Element> right = new ArrayList<Element>();
        int middle = list.size() / 2;

        for (int i = 0; i < list.size(); i++) {
            if (i < middle) {
                left.add(list.get(i));
            } else {
                right.add(list.get(i));
            }
        }
        // use recursion
        left = mergeSort(left);
        right = mergeSort(right);
        return merge(left, right);
    }