# Selection Sort

> Find the smallest item left. Move it to the front. Do it again and again.

**Field:** Software Development  
**Category:** Algorithms & Data Structures  
**Also known as:** Selection Sorting, Select Sort

## Think of it like

It is like picking teams by height. You find the shortest child, put them first, then find the next shortest.

## Definition

Selection sort finds the smallest item left and swaps it to the front. Then it does the same for the rest of the list, one place at a time. It always takes about n squared steps, even if the list is already sorted. It makes very few swaps, at most one per place. That only helps when moving items costs a lot.

## Example

Jack sorts five cards: he finds the 1 and swaps it first, then finds the 2, and so on to the end.

## Why it matters

It is one of the easiest sorts to understand, so it is often taught first. It also shows why some sorts are slow.

## Common mistake

Thinking it speeds up on sorted data. It still checks every item left on every pass.

## Three principles

- **Find the smallest.** Scan what is left each pass.
- **Few swaps.** At most one per place.
- **Always slow.** About n squared, even when sorted.

## Related terms

- [Sorting Algorithm](https://learn.benibix.com/term/development/sorting-algorithm)
- [Insertion Sort](https://learn.benibix.com/term/development/insertion-sort)
- [Bubble Sort](https://learn.benibix.com/term/development/bubble-sort)
- [Quicksort](https://learn.benibix.com/term/development/quicksort)
- [Time Complexity](https://learn.benibix.com/term/development/time-complexity)

## Told apart from

- [Insertion Sort vs Selection Sort](https://learn.benibix.com/compare/insertion-sort-vs-selection-sort): Insertion sort slides each item back into place. It is quick when the list is nearly in order. Selection sort looks for the smallest item on each pass. It is always slow.

![Two panels sorting the cards 5, 2, 4, 1. Insertion sort: the left part grows sorted, and the next card slides back into its place among them. Selection sort: the smallest card left, 1, is found and swapped to the front, then the next smallest, and so on.](https://learn.benibix.com/diagrams/dev7-simple-sorts.svg)

---

Source: https://learn.benibix.com/term/development/selection-sort
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-19
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
