CODE INTERVIEW AND TECHNICAL TEST PREP

Selection Sort in a nutshell — how, when & where

knowledge snippets for your next technical test, JavaScript edition

Aphinya Dechalert
Modules&Methods
Published in
4 min readNov 7, 2019

--

image by Aphinya Dechalert

Selection sort is one of the easiest sorting algorithms to understand. In part, because there is minimal complexity. However, simplicity does come with its pitfalls.

Here is a quick low down on what selection sort is, how to write one, when and where you’d most likely encounter it.

How it works

Selection sort has two things going for it — a current minim and a current item.

The current item moves through the array and decides if the it’s smaller than the current minimum. If it is, the current item gets the new marker as the new current minimum.

--

--

Aphinya Dechalert
Modules&Methods

Where Development Meets Storytelling: Tech Writer, Editor & Dev Advocate. Translating Complexity into Clarity. DM me. linkedin.com/in/dechalert