diff --git a/classpath/java/util/Arrays.java b/classpath/java/util/Arrays.java index ce59ec22b1..c4675e7df0 100644 --- a/classpath/java/util/Arrays.java +++ b/classpath/java/util/Arrays.java @@ -11,6 +11,19 @@ public class Arrays { return (a == null && b == null) || (a != null && a.equals(b)); } + public static void sort(T[] array, Comparator comparator) { + // insertion sort + for (int j = 1; j < array.length; ++j) { + T t = array[j]; + int i = j - 1; + while (i >= 0 && comparator.compare(array[i], t) > 0) { + array[i + 1] = array[i]; + i = i - 1; + } + array[i + 1] = t; + } + } + public static List asList(final T ... array) { return new List() { public String toString() {