Iterative selects the maximum element in the unsorted subarray, and swaps it with the last element in the subarray. Iterative Sorts are generally bad unless the data set is relatively small

  • Minimal data movement
  • No optimization possible

Evaluation

Best CaseAverage CaseWorst CaseStableAdaptiveIn-place
Selection SortNoNoYes

Pseudocode

loop n from end to start {
	maxIndex
	loop i from 0 to n {
		if array[i] > array[maxIndex]
			maxIndex := i
	}	
	swap elements at n and maxIndex
}

See Also

Sorting Algorithms