šŸŽ™ Free live masterclass Ā· Sun, 29 Nov, 7:00 pm IST Ā· Java Full Stack roadmap Register free →
Skills101

Sorting algorithm visualiser

Watch bubble, insertion, merge, quick and heap sort move bars on screen, with speed control and comparison counts.

Intermediateā± 8–12 hours🪜 7 stepsJavaScriptHTML Canvas or React

What you'll learn

  • ā—†How each sort really works
  • ā—†Generators/async for step-by-step animation
  • ā—†Time complexity in practice

What you'll build

  • āœ“Random array of 20–200 bars
  • āœ“Five algorithms
  • āœ“Speed slider, pause and step
  • āœ“Counts comparisons and swaps

Step-by-step guide

  1. 1

    Draw bars

    Render an array as divs or canvas rectangles; height = value.

  2. 2

    Write sorts as generators

    function* bubble(a) { ... yield {type: "compare", i, j} ... yield {type: "swap", i, j} } so the UI can play one step at a time.

  3. 3

    Animation loop

    Pull the next step every N ms (from the speed slider), colour compared bars yellow and swapped bars red.

  4. 4

    Merge and quick sort

    For merge sort yield "overwrite" steps (index, value); for quick sort show the pivot in a different colour.

  5. 5

    Controls

    Buttons: new array, start, pause, step; disable inputs while running.

  6. 6

    Stats

    Count comparisons and swaps; show them next to the expected O(n²) or O(n log n).

  7. 7

    Deploy

    Host it free on GitHub Pages or Netlify and put the link in your resume.

šŸš€ Make it stand out

  • +Side-by-side race between two algorithms
  • +Sound for each comparison
  • +Add counting sort and radix sort