Here you can find the source of sortArrayAndReturnIndex(double[] p, String t)
public static int[] sortArrayAndReturnIndex(double[] p, String t)
//package com.java2s; //License from project: Open Source License public class Main { public static int[] sortArrayAndReturnIndex(double[] p, String t) { int[] ret = new int[p.length]; for (int i = 0; i < ret.length; i++) { ret[i] = i;//from ww w . j a va 2 s .c o m } if (t.equals("desc")) { //buyukten kucuge sirala double temp = p[0]; int q = 0; for (int i = 0; i < p.length; i++) { for (int j = i; j < p.length; j++) { if (p[j] > p[i]) { temp = p[i]; p[i] = p[j]; p[j] = temp; q = ret[i]; ret[i] = ret[j]; ret[j] = q; } } } } if (t.equals("asc")) { //kucukten buyuge sirala double temp = 0; int q = 0; for (int i = 0; i < p.length; i++) { for (int j = i; j < p.length; j++) { if (p[j] < p[i]) { temp = p[i]; p[i] = p[j]; p[j] = temp; q = ret[i]; ret[i] = ret[j]; ret[j] = q; } } } } return ret; } }