Sort { public static void insertSort(int[] data) { int len = data.length; for (int i = 0; i < len; i++) { int currVal = data[i]; int preIndex = i - 1; while (preIndex >= 0 && data[preIndex] > currVal) { data[preIndex + 1] = data[preIndex]; preIndex--; } data[preIndex + 1] = currVal; } }  static void maopaoSort(int[] data); static void quickSort(int[] data); static void insertSort(int[] data); static void selectSort(int[] data); static void quickSort(int[] data, int left, int right); static void quickSort2(int[] arr, int l, int r); static void heapSort(int[] arr, int node); static void buildHeap(int[] arr, int length); static void adjustHeap(int[] arr, int index, int length); static void swap(int[] arr, int a_index, int b_index);  }
@Test public void testInertSort() { int[] data = {1, 4, 5, 3, 2}; Sort.insertSort(data); for (int i : data) { System.out.println(i); } }