/** * Sorts an array according to the natural ascending order using mergesort. * * <p> * This sort is guaranteed to be <i>stable</i>: equal elements will not be * reordered as a result of the sort. An array as large as {@code a} will be * allocated by this method. * * @param a * the array to be sorted. */ public static void mergeSort(final long a[]) { mergeSort(a, 0, a.length); } /**
/** * Sorts an array according to the order induced by the specified comparator * using mergesort. * * <p> * This sort is guaranteed to be <i>stable</i>: equal elements will not be * reordered as a result of the sort. An array as large as {@code a} will be * allocated by this method. * * @param a * the array to be sorted. * @param comp * the comparator to determine the sorting order. */ public static void mergeSort(final long a[], LongComparator comp) { mergeSort(a, 0, a.length, comp); } /**
/** * Sorts the specified range of elements according to the natural ascending * order using mergesort. * * <p> * This sort is guaranteed to be <i>stable</i>: equal elements will not be * reordered as a result of the sort. An array as large as {@code a} will be * allocated by this method. * * @param a * the array to be sorted. * @param from * the index of the first element (inclusive) to be sorted. * @param to * the index of the last element (exclusive) to be sorted. */ public static void mergeSort(final long a[], final int from, final int to) { mergeSort(a, from, to, a.clone()); } /**
/** * Sorts the specified range of elements according to the order induced by the * specified comparator using mergesort. * * <p> * This sort is guaranteed to be <i>stable</i>: equal elements will not be * reordered as a result of the sort. An array as large as {@code a} will be * allocated by this method. * * @param a * the array to be sorted. * @param from * the index of the first element (inclusive) to be sorted. * @param to * the index of the last element (exclusive) to be sorted. * @param comp * the comparator to determine the sorting order. */ public static void mergeSort(final long a[], final int from, final int to, LongComparator comp) { mergeSort(a, from, to, comp, a.clone()); } /**