Selection sort will find the largest value in the remaining array until the length of the remaining array is 1.
class SelectionSortAlgorithm { public void SelectionSort(int[] array) { int tempPosition = 0; for (int i = 0; i < array.Length; i++) { tempPosition = i; for (int j = i + 1; j < array.Length; j++) { if (array[j] < array[tempPosition]) { tempPosition = j; } } if (tempPosition != i) { int temp = array[i]; array[i] = array[tempPosition]; array[tempPosition] = temp; } } } }