/// <summary> /// Method for bubble sort input array using interface /// </summary> /// <param name="inputArray">input array</param> /// <param name="comparer">object for compare two array</param> public static void BubbleSortInterface(int[][] inputArray, IComparerArray comparer) { int depthSort = inputArray.GetLength(0); while (depthSort != 1) { for (int i = 0; i < depthSort - 1; ++i) { if (comparer.Compare(inputArray[i], inputArray[i + 1]) > 0) { Swap(ref inputArray[i], ref inputArray[i + 1]); } } depthSort--; } }
/// <summary> /// Method for bubble sort input array /// </summary> /// <param name="inputArray">input array</param> /// <param name="comparer">object for compare two array</param> public static void BubbleSortInterface(int[][] inputArray, IComparerArray comparer) { if (inputArray == null) { throw new ArgumentNullException($"Argument {nameof(inputArray)} is null"); } if (comparer == null) { throw new ArgumentNullException($"Argument {nameof(comparer)} is null"); } if (inputArray.GetLength(0) == 0) { throw new ArgumentOutOfRangeException($"Argument`s {nameof(inputArray)} length is 0"); } Func <int[], int[], int> delegateInput = comparer.Compare; BubbleSortDelegate(inputArray, delegateInput); }