cat case-studies/easy-sorting.md
Easy Sorting
- JavaScript
- HTML
- CSS
## the problem
Data-structures courses teach sorting as pseudocode on a slide. Most students memorize the steps without ever seeing the array move - and it shows in exams and interviews.
Built during my BSc CSIT while studying DSA myself. The goal was a tool I would have wanted: pick an algorithm, watch every comparison and swap, control the speed.
## try it - live sorting playground
Rebuilt natively for this page. Pick an algorithm, drag the sliders, and watch every comparison and swap - the same idea behind the original project, running right here.
bubbleSort() · O(n²) · stable · the one everyone learns first · step 0/570
## screens
## constraints & tradeoffs
- Zero dependencies - every animation frame, timer, and state transition written by hand in vanilla JS.
- Step-accurate visualization: the animation must reflect the real algorithm, not a look-alike.
- Runs smoothly on the low-end laptops most students actually have.
## architecture
vanilla JS core ├─ algorithm runner ──► emits step events (compare / swap) ├─ renderer ──► DOM bars, batched updates └─ controls ──► speed, size, algorithm select, replay
## key decisions
Algorithms emit steps, the renderer replays them
Each sort runs to completion producing a step log, and the visualizer plays it back. That separation made every new algorithm a pure function - no animation code inside the sort.
## results & lessons
- Live at easysorting.netlify.app and used by classmates preparing for DSA exams.
- The step-event pattern became my template for the later Stack visualizer.
- Lesson: building the visualizer taught me more about sorting than the course did.