/** * Sort an double array using Quick Sort. * @param sortVal The double array to be sorted. * @return The sorted indexes. */ public static int[] sortDesc(final List<Double> sortVal) { return qSortDouble(sortVal, false); }
/** * Sort an double array using Quick Sort. * @param sortVal The double array to be sorted. * @return The sorted indexes. */ public static int[] sortDesc(List<Double> sortVal) { return qSortDouble(sortVal, false); }
/** * Quick sort internal * @param l The list to sort. * @param asc Ascending/Descendingly parameter. * @return The sorted indexes. */ private static int[] qSortDouble(final List<Double> l, final boolean asc) { final int[] idx = new int[l.size()]; List<Integer> idxList = new ArrayList<>(); for (int i = 0; i < l.size(); i++) { idxList.add(i); } idxList = qSortDouble(l, idxList, asc); for (int i = 0; i < l.size(); i++) { idx[i] = idxList.get(i); } return idx; }
/** * Quick sort internal * @param l The list to sort. * @param asc Ascending/Descendingly parameter. * @return The sorted indexes. */ private static int[] qSortDouble(List<Double> l, boolean asc) { count = 0; int[] idx = new int[l.size()]; List<Integer> idxList = new ArrayList<Integer>(); for(int i=0;i<l.size();i++) idxList.add(i); //System.out.print("Sorting..."); idxList = qSortDouble(l, idxList, asc); for(int i=0;i<l.size();i++) idx[i] = idxList.get(i); //System.out.println("[Done.]"); return idx; } /**
left = qSortDouble(l, left, asc); count++; if(right.size() > 1) right = qSortDouble(l, right, asc); List<Integer> newIdx = new ArrayList<Integer>(); newIdx.addAll(left);
left = qSortDouble(l, left, asc); right = qSortDouble(l, right, asc);