public void SelectionSort() // ascending order { for (int i = 1; i <= List.Count; i++) // go through the list { ListClass minimum = (ListClass)List[i-1]; int min = i - 1; for (int j = i;j <= List.Count-1; j++) { ListClass cur = (ListClass)List[j]; if (minimum.getNum() > cur.getNum()) min = j; // min equals smallest in list j } swap(List, i-1, min); } Console.WriteLine("Array after selection sort: "); foreach (ListClass cur in List) { cur.Display(); } public static void swap(ArrayList List, int x, int y) { object temp = List[x]; List[x] = List[y]; List[y] = temp; } public void Display() { foreach (ListClass cur in List) { cur.Display(); } }