SortingD1Phase 1arraymin-selectionintro

Selection Sort

Selection-based sorting walkthrough focused on invariant tracking across partitions.

Easy Explanation

Selection Sort finds the smallest remaining value each pass and places it at the next sorted position.

Renderer Mode

`Simple` uses abstract, short-form-friendly visuals. `Advanced` keeps the current detailed view.

Arrays + Grid
Visualizer
O(n^2)Selection Sort
Deterministic minimum-candidate tracking across the unsorted suffix with a single swap per pass.

Pass

n/a

Comparisons

0

Swaps

0

Result

Sorting

Ready

Press Play or Step to start execution.

No values available for visualization.
Selection Sort Implementation
Pseudocode + TypeScript
Reference implementation examples are intentionally abstracted from the playback engine so learners can map concepts to code.
pseudocode
function selectionSort(values):
  n <- length(values)

  for pass from 0 to n - 2:
    minIndex <- pass

    for i from pass + 1 to n - 1:
      if values[i] < values[minIndex]:
        minIndex <- i

    if minIndex != pass:
      swap values[pass], values[minIndex]

  return values
1.00xNo Run