using System.Collections.Generic;
public static void Main()
Console.WriteLine("Hello World");
int[] values = {9, 3, 5, 8, 20, 300, 2, 2, 0, -32, 32};
List<int> testValuesToSort = new List<int>(values);
SortUtility test1 = new SortUtility(testValuesToSort, ESortMethods.Bubble);
Console.WriteLine("Goodbye.");
public enum ESortMethods {None, Bubble, Insert, Select, Shell, Merge, Heap, Quick, Quick3}
private List<int> inputList;
private List<int> outputList;
public delegate List<int> Sorter (List<int> listToSort);
private List<int> noSort (List<int> listToSort) {return listToSort;}
private List<int> bubbleSort (List<int> listToSort)
int[] intList = listToSort.ToArray();
for ( int iterator = 0; iterator < intList.Length - 1; iterator++ )
int itemA = intList[iterator];
int itemB = intList[iterator + 1];
cleanPassThrough = false;
int tempHoldingSpot = itemA;
intList[iterator] = itemA;
intList[iterator + 1] = itemB;
} while (cleanPassThrough == false);
Console.WriteLine("Within the BubbleSort() method, the readout of intList:");
foreach (int intItem in intList)
Console.Write(intItem.ToString());
return new List<int>(intList);
public SortUtility(List<int> input, ESortMethods sortMethod)
inputList = new List<int>(input);
case ESortMethods.Bubble:
sortHandler = bubbleSort;
Console.WriteLine("Before sort: ");
foreach (int intItem in inputList)
Console.Write(intItem.ToString());
Console.WriteLine("After sort:");
foreach (int intItem in inputList)
Console.Write(intItem.ToString());