C#折半插入排序算法演示
public static void BinarySort (int[] list) { for (int i = 1; i < list.Length; i+ +) { int low = 0; int high = i - 1; int Temp = list [i]; //Find while (low <= high) { int mid = (low + high) / 2; IF (Temp < list [mid]) high = mid - 1; else low = mid + 1; } //backward shift for (int j = i - 1; j > = low; j-) list [j + 1] = list [j]; list [low] = Temp; } }