Skip to content

Resource · Guide or article

Selection Sort

Selection sort summary: an in-place comparison sort, simple to write and slow on large lists.

Reviewed

Open the original: Selection Sort (opens the original site in a new tab)

Add to a roadmap

Keep this resource with a roadmap you follow. It appears as your own extra resource; the roadmap's steps don't change and it doesn't count toward your tracked steps.

Source content: English

Read this in other languages: Português. Selection sort is a sorting algorithm, specifically an in-place comparison sort. It has O(n2) time complexity, making it inefficient on large lists, and generally performs worse than the similar insertion sort. Selection sort is noted for its simplicity, and it has performance advantages over more complicated algorithms in certain situations, particularly where auxiliary memory is limited.

PrepKit overview

PrepKit editors wrote and reviewed this overview from the source repository. It is not text from the resource itself.

Suited to
The source does not state a level
Format
Reference

What it covers

  • Where it fits: worse than insertion sort in general, with some benefit when auxiliary memory is limited.
  • Complexity table: n squared in every case, memory 1, not stable.

How to use it

PrepKit study advice, not a claim made by the source.

Write it and explain with a small example containing equal keys why it is not stable.

Scope and limitations

Very short; the procedure is shown only through animations, and there is one Wikipedia link. A Portuguese version is linked.

Access and format

Free English README on GitHub in trekhleb/javascript-algorithms, MIT license.

Reviewed by PrepKit on Oct 2, 2026. Listing source commit: 85293e3e2b88

Evidence behind this overview
  • src/algorithms/sorting/selection-sort/README.md

Pages that include this

Get the PrepKit newsletter

Optional. You don't need it to use PrepKit.

How we handle your email