using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ch7_5
{
    class DelegateBubleSort
    {
        public delegate bool Comparator(int element1, int element2);
        public static void sortArray(int[] array, Comparator compare)
        {
            for (int p = 0; p < array.Length; p++)
                for (int i = 0; i < array.Length - 1; i++)
                {
                    if (compare(array[i], array[i + 1]))
                    {
                        swap(ref array[i], ref array[i + 1]);
                    }
                }
        }
        private static void swap(ref int first, ref int second)
        {
            int hold = first;
            first = second;
            second = hold;
        }
    }
}
