1 package iYou.neugle.sort; 2 3 public class Shell_sort { 4 public static void ShellSort(double[] array) { 5 int n = array.length; 6 for (int gap = n / 2; gap > 0; gap /= 2) { 7 for (int i = gap; i < n; i++) { 8 if (array[i] < array[i - gap]) { 9 double temp = array[i]; 10 int j = i - gap; 11 while (j >= 0 && array[j] > temp) { 12 array[j + gap] = array[j]; 13 j -= gap; 14 } 15 array[j + gap] = temp; 16 } 17 } 18 } 19 } 20 }