Here you can find the source of sortIndexesDescending(final double[] in)
Parameter | Description |
---|---|
array | a parameter |
public static Integer[] sortIndexesDescending(final double[] in)
//package com.java2s; //License from project: Open Source License import java.util.Arrays; import java.util.Comparator; public class Main { /**//from w ww . j a v a2s . c o m * Returns an array of indexes into the given array, where the indexes are ordered such that * they sort their targets from greatest to least. * @param array * @return */ public static Integer[] sortIndexesDescending(final double[] in) { Integer[] result = new Integer[in.length]; for (int i = 0; i < result.length; i++) result[i] = i; Comparator<Integer> comparator = new Comparator<Integer>() { @Override public int compare(Integer i1, Integer i2) { return Double.compare(in[i1], in[i2]) * -1; } }; Arrays.sort(result, comparator); return result; } }