private static void DisplaySortingAlgorithmsComparison <T>(T[] array, bool sortBeforehand, Comparison <T> comparison = null) where T : IComparable <T> { if (sortBeforehand) { Array.Sort(array, comparison); } T[] array1 = (T[])array.Clone(); T[] array2 = (T[])array.Clone(); T[] array3 = (T[])array.Clone(); string insertionSortMessage = string.Format("Insertion sort for {0}[]", typeof(T).Name).PadRight(35, '.') + ": "; DisplayExecutionTime(() => { SortingAlgorithms.InsertionSort(array1); }, insertionSortMessage); string selectionSortMessage = string.Format("Selection sort for {0}[]", typeof(T).Name).PadRight(35, '.') + ": "; DisplayExecutionTime(() => { SortingAlgorithms.SelectionSort(array2); }, selectionSortMessage); string quicksortMessage = string.Format("Quicksort for {0}[]", typeof(T).Name).PadRight(35, '.') + ": "; DisplayExecutionTime(() => { SortingAlgorithms.Quicksort(array3, 0, array3.Length - 1); }, quicksortMessage); }