Here you can find the source of sortIndex(double[] A)
public static int[] sortIndex(double[] A)
//package com.java2s; //License from project: Open Source License public class Main { public static int[] sortIndex(double[] A) { double[] sortedA = new double[A.length]; int[] index = new int[A.length]; double valueToInsert; int holePos; for (int i = 0; i < sortedA.length; i++) { valueToInsert = A[i];/*from www . ja v a 2s .c om*/ holePos = i; while (holePos > 0 && valueToInsert < sortedA[holePos - 1]) { sortedA[holePos] = sortedA[holePos - 1]; index[holePos] = index[--holePos]; } sortedA[holePos] = valueToInsert; index[holePos] = i; } return index; /* int[] retindex=new int[A.length]; retindex[0]=index[0]; int k=1; for (int i=1;i<sortedA.length;i++){ if (sortedA[i]>sortedA[i-1]){ retindex[k++]=index[i]; } } return Arrays.copyOf(retindex, k); */ } }