@Test public void multiSort() throws Exception { SortUtil sortUtil = new SortUtil(); List<SortUtil.SortObject<Double>> resultList = sortUtil.multiSort(100, false); for (SortUtil.SortObject<Double> each : resultList) { System.out.println(each.toString()); } }
public List<SortObject<Double>> multiSort(int num, boolean ascend) { List<SortObject<Double>> resultList = new ArrayList<>(); for (int i = 0; i < num; i++) { SortObject<Double> eachObject = new SortObject<>("element" + (i + 1), (int) (Math.random() * num) + 1, Math.random()); resultList.add(eachObject); } resultList.sort((o1, o2) -> { if (o1.heavy == o2.heavy) { return o1.accurate - o2.accurate > 0 ? 1 : -1; } return o1.heavy - o2.heavy; }); if (!ascend) { Collections.reverse(resultList); } return resultList; }
SortUtil { public List<SortObject<Double>> multiSort(int num, boolean ascend) { List<SortObject<Double>> resultList = new ArrayList<>(); for (int i = 0; i < num; i++) { SortObject<Double> eachObject = new SortObject<>("element" + (i + 1), (int) (Math.random() * num) + 1, Math.random()); resultList.add(eachObject); } resultList.sort((o1, o2) -> { if (o1.heavy == o2.heavy) { return o1.accurate - o2.accurate > 0 ? 1 : -1; } return o1.heavy - o2.heavy; }); if (!ascend) { Collections.reverse(resultList); } return resultList; } }
SortUtil { public List<SortObject<Double>> multiSort(int num, boolean ascend) { List<SortObject<Double>> resultList = new ArrayList<>(); for (int i = 0; i < num; i++) { SortObject<Double> eachObject = new SortObject<>("element" + (i + 1), (int) (Math.random() * num) + 1, Math.random()); resultList.add(eachObject); } resultList.sort((o1, o2) -> { if (o1.heavy == o2.heavy) { return o1.accurate - o2.accurate > 0 ? 1 : -1; } return o1.heavy - o2.heavy; }); if (!ascend) { Collections.reverse(resultList); } return resultList; }  }
SortUtil { public List<SortObject<Double>> multiSort(int num, boolean ascend) { List<SortObject<Double>> resultList = new ArrayList<>(); for (int i = 0; i < num; i++) { SortObject<Double> eachObject = new SortObject<>("element" + (i + 1), (int) (Math.random() * num) + 1, Math.random()); resultList.add(eachObject); } resultList.sort((o1, o2) -> { if (o1.heavy == o2.heavy) { return o1.accurate - o2.accurate > 0 ? 1 : -1; } return o1.heavy - o2.heavy; }); if (!ascend) { Collections.reverse(resultList); } return resultList; }  static void setIsPrint(boolean isPrint); static int[] initArray(final int n); static void print(int[] data); static void selectSort(int[] data); static void insertSort(int[] data); static void binaryInsertionSort(int[] data); static void shellSort(int[] data); static void bubbleSort(int[] data); static void quickSort(int[] data); static void mergeSort(int[] data); static void heapSort(int[] data); static void radixSort(int[] data, int maxBit); static int getDigitBit(int data); static int getFigure(int data, int n); List<SortObject<Double>> multiSort(int num, boolean ascend); }
SortUtil { public List<SortObject<Double>> multiSort(int num, boolean ascend) { List<SortObject<Double>> resultList = new ArrayList<>(); for (int i = 0; i < num; i++) { SortObject<Double> eachObject = new SortObject<>("element" + (i + 1), (int) (Math.random() * num) + 1, Math.random()); resultList.add(eachObject); } resultList.sort((o1, o2) -> { if (o1.heavy == o2.heavy) { return o1.accurate - o2.accurate > 0 ? 1 : -1; } return o1.heavy - o2.heavy; }); if (!ascend) { Collections.reverse(resultList); } return resultList; }  static void setIsPrint(boolean isPrint); static int[] initArray(final int n); static void print(int[] data); static void selectSort(int[] data); static void insertSort(int[] data); static void binaryInsertionSort(int[] data); static void shellSort(int[] data); static void bubbleSort(int[] data); static void quickSort(int[] data); static void mergeSort(int[] data); static void heapSort(int[] data); static void radixSort(int[] data, int maxBit); static int getDigitBit(int data); static int getFigure(int data, int n); List<SortObject<Double>> multiSort(int num, boolean ascend);  }