Selection Sort
noun
say it: “suh-LEK-shun sort” /səˈlɛkʃən sɔːrt/
A simple sort that finds the smallest item left and swaps it to the front, again and again.
What is selection sort?
Selection sort puts a list in order by finding the smallest item of the unsorted part and swapping it to the front of that part, pass after pass, the way you might write a leaderboard by picking out the fastest time again and again. It always compares every pair, so it is O(n²) even on a list that's already sorted, but it makes at most one swap per pass.
In a sentence
- “Selection sort made 15 comparisons on six lap times, even when they were already in order.”
Level: Apprentice · More Data Structures terms at this level
Updated