插入排序
1 int[] insertionSort(int arr[]) {//插入排序 2 int preIndex,current; 3 for(int i = 1; i < arr.length; i++) { 4 preIndex = i - 1; 5 current = arr[i]; 6 while (preIndex >= 0 && arr[preIndex] > current) { 7 arr[preIndex + 1] = arr[preIndex]; 8 preIndex--; 9 } 10 arr[preIndex + 1] = current; 11 } 12 return arr; 13 }