static void WriteToFile(string path, IIterable <int> iterator)
 {
     using (StreamWriter file = new StreamWriter(path))
     {
         while (iterator.HasNext())
         {
             file.WriteLine(iterator.Next().ToString());
         }
     }
 }
        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();
                }
            }
        }