using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Sort { class ShellSorter { public static int[] Sort(int[] a) { ShellSort(a); return a; }
public static void ShellSort(int[] myArray) { int i, j, increment; int temp; for (increment = myArray.Length / 2; increment > 0; increment /= 2) { for (i = increment; i < myArray.Length; i++) { temp = myArray[i]; for (j = i; j >= increment; j -= increment) { if (temp < myArray[j - increment]) myArray[j] = myArray[j - increment]; else break; } myArray[j] = temp; } } }