Ten algorithms.
One frame at a time.
Sorting Visualizer 🧮 is a desktop app that renders comparisons, swaps, and pivots as they happen — driven by Python generators that pause mid-sort so Pygame can draw, and play a tone for every value it touches.
Ten algorithms, three complexity families
Every algorithm the Pygame app implements, with the complexity and stability profile you'd want before picking one for real data.
Five files, one frame per call
Each pass through the main loop touches these modules in the same order — main.py hands off to program.py, which steps the generator, then hands the result to drawing.
why yield, specifically
A normal sorting function runs to completion the instant you call it — Pygame would freeze until it returned.
sorting_algorithms.py writes each algorithm as a generator: it does one comparison or swap,
then yields control back to program.py. That function stores its place in the loop,
so calling next() on it later resumes exactly where it left off. The main loop calls
next() once per frame, draws whatever state came back, and handles input in between —
which is also what makes pause, step-through, and instant reset possible without touching the algorithm code.
Get the Pygame version running
The real thing — full HUD, keyboard shortcuts, and the sound engine — needs Python and Pygame on your machine.