MCPcopy Create free account
hub / github.com/AstroImageJ/astroimagej / rank

Method rank

ij/src/main/java/ij/util/Tools.java:298–315  ·  view source on GitHub ↗

Returns a sorted list of indices of the specified double array. Modified from: http://stackoverflow.com/questions/951848 by N.Vischer.

(double[] values)

Source from the content-addressed store, hash-verified

296 Modified from: http://stackoverflow.com/questions/951848 by N.Vischer.
297 */
298 public static int[] rank(double[] values) {
299 int n = values.length;
300 final Integer[] indexes = new Integer[n];
301 final Double[] data = new Double[n];
302 for (int i=0; i<n; i++) {
303 indexes[i] = Integer.valueOf(i);
304 data[i] = Double.valueOf(values[i]);
305 }
306 Arrays.sort(indexes, new Comparator<Integer>() {
307 public int compare(final Integer o1, final Integer o2) {
308 return data[o1].compareTo(data[o2]);
309 }
310 });
311 int[] indexes2 = new int[n];
312 for (int i=0; i<n; i++)
313 indexes2[i] = indexes[i].intValue();
314 return indexes2;
315 }
316
317 /** Returns a sorted list of indices of the specified String array. */
318 public static int[] rank(final String[] data) {

Callers 7

sortArrayMethod · 0.95
getRankPositionsMethod · 0.95
sortMethod · 0.95
analyzeMethod · 0.95
findMaximaMethod · 0.95
getIndexedPlotObjectsMethod · 0.95
sortNumericallyMethod · 0.95

Calls 2

valueOfMethod · 0.80
sortMethod · 0.45

Tested by

no test coverage detected