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.
Pass
n/a
Comparisons
0
Swaps
0
Result
Sorting
Press Play or Step to start execution.
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