public override void Sort(int[] array) { bool swapped = true; while (swapped) { swapped = false; for (int i = 0; i < array.Length - 1; ++i) { if (array[i] > array[i + 1]) { swapped = true; _swapper.Swap(i, i + 1, array); Swapped++; } } if (!swapped) { break; } for (int i = array.Length - 2; i >= 0; --i) { if (array[i] > array[i + 1]) { swapped = true; _swapper.Swap(i, i + 1, array); Swapped++; } } } }
void QuickSortArray(int[] array, int Left, int Right) { int L = Left; int R = Right; int pivotValue = array[(Left + Right) / 2]; do { while (array[L] < pivotValue) { L++; } while (pivotValue < array[R]) { R--; } if (L <= R) { _swapper.Swap(L, R, array); Swapped++; L++; R--; } } while (L < R); if (Left < R) { QuickSortArray(array, Left, R); } if (L < Right) { QuickSortArray(array, L, Right); } }