- 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;
- }
- }
- //该片段来自于http://www.codesnippet.cn/detail/060920135714.html
来源: http://www.codesnippet.cn/detail/060920135714.html