Simple solution to create an indexer array: sort the indexer comparing the data values:
final Integer[] idx = { 0, 1, 2, 3 };
final float[] data = { 1.7f, -0.3f, 2.1f, 0.5f };
Arrays.sort(idx, new Comparator<Integer>() {
@Override public int compare(final Integer o1, final Integer o2) {
return Float.compare(data[o1], data[o2]);
}
});
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…