public static void BubbleSort(int[] array, IComparer comparator, IIterable iterator) { bool isSort = true; while (isSort) { isSort = false; for (int current = iterator.GetStart(); !iterator.IsEnd(); current = iterator.GetCurrent()) { int next = iterator.GetNext(); if (comparator.Compare(array[current], array[next]) > 0) { Swap(ref array[current], ref array[next]); isSort = true; } iterator.Next(); } } }