Visualizing Sorting Algorithms in 2D Space

In each image below, we start with a row of unsorted pixels at the top, and then watch as a sorting algorithm progressively sorts the pixels, eventually arriving at a fully sorted row at the bottom.

Bubble Sort
Cocktail Sort
Comb Sort
Heap Sort
Insertion Sort
Quick Sort
Selection Sort
Shell Sort
Odd Even Sort
Stooge Sort
Merge Sort
Radix Sort

These were inspired by some delightful animated sorting algorithm visualizations that surfaced on the web recently: 1, 2

The source code used to generate the visualizations seen in this post is available on GitHub. Thanks to franciscouzo for open sourcing his sort visualization tool that was forked & modified to generate these.

Engineering at OpenAI. Building products, tools, and data visualizations.