diff --git a/core/java/src/org/broadinstitute/sting/utils/Utils.java b/core/java/src/org/broadinstitute/sting/utils/Utils.java index 791d01036..fe8aefe84 100755 --- a/core/java/src/org/broadinstitute/sting/utils/Utils.java +++ b/core/java/src/org/broadinstitute/sting/utils/Utils.java @@ -280,6 +280,27 @@ public class Utils { return permutation; } + public static Integer[] SortPermutation( List A ) + { + final Object[] data = A.toArray(); + + class comparator implements Comparator + { + public int compare(Integer a, Integer b) + { + return ((T)data[a]).compareTo(data[b]); + } + } + Integer[] permutation = new Integer[A.size()]; + for (int i = 0; i < A.size(); i++) + { + permutation[i] = i; + } + Arrays.sort(permutation, new comparator()); + return permutation; + } + + public static int[] PermuteArray(int[] array, Integer[] permutation) { int[] output = new int[array.length];