Pseudocode

func Selection(s []int) {
	for i := 0; i < len(s); i++ {
		min := s[i]
		for j := i + 1; j < len(s); j++ {
			if s[j] < min {
				min = s[j]
			}
		}
		s[i] = min
	}
}

Relation to Heapsort

Heapsort is just a selection sort backed by a heap rather than array

Properties

Worst TimeAverage TimeBest TimeWorst SpaceAverage SpaceStabilityAdaptive
Not StableNot Adaptive

References