🧰 Developer’s toolbox: 🔘 Selection Sort

Vee Lesyk
Dots and Spaces
Published in
1 min readSep 14, 2019
Selection Sort.

Wikipedia says:

Selection sort is an in-place comparison sort. It has O(n2) complexity, making it inefficient on large lists, and generally performs worse than the similar insertion sort. Selection sort is noted for its simplicity, and also has performance advantages over more complicated algorithms in certain situations.

The algorithm finds the minimum value, swaps it with the value in the first position, and repeats these steps for the remainder of the list. It does no more than n swaps, and thus is useful where swapping is very expensive.

Github repo: link.

Swift

SelectionSort.swift

TypeScript

SelectionSort.ts

Output

Selection Sort Output.
Selection.

P.S. We would be happy to see comments according to mistakes & typos.

--

--

Vee Lesyk
Vee Lesyk

Written by Vee Lesyk

#h+ #livemoredomore Adventurer. Unique experience wizard. Maker of things. Convergence commander. Information warlock. Problem solver. System: ☉; Planet: ♁.