public static void ShellSort<T>(T[] array) where T : IComparable { int length = array.Length; for (int h = length / 2; h > 0; h = h / 2) { //here is insert sort for (int i = h; i < length; i++) { T temp = array[i]; if ((array[i -h]) < 0) { for (int j = 0; j < i; j += h) { if ((array[j]) < 0) { temp = array[j]; array[j] = array[i]; array[i] = temp; } } } } } }