Tiem Cong Nghe

Showing suggestions.

Opening the store's index…
↑↓ to move↵ to openesc to close
Tiem Cong Nghe search
Animationv1.0.0~16 KB gzipped

Quick Sort Animation

Quick sort, step by step: the pivot, Hoare's two pointers and a call stack that stays shallow

FreeFree
Format

.zip · HTML / CSS / JS · v1.0.0

Free — no account, no email. Always the newest version.

Live preview

Version
Preview width
Zoom

About

Quick sort is easy to say and hard to see. This player shows every step of it: the three values median-of-three looks at, the pivot they choose, Hoare's two pointers i and j walking toward each other, the swaps sliding into place, and the split. Finished stretches turn green, and the call stack beside it shows the trick that keeps quick sort safe: recurse into the smaller side, loop on the bigger one, so the stack never gets deeper than ⌈log₂ n⌉.

  • Exactly the listing on the Quick Sort page, and its code lights up line by line as it runs
  • Captions in plain words ("values[j] = 39 is not above 39: j stops here") for every step
  • Random, sorted, reversed or many-duplicates input from a seed, or your own numbers
  • Play, step, scrub and change speed with the mouse or the keyboard; it loops for a slide or a video
  • Every colour, radius and timing is a CSS custom property; light and dark follow your page
  • Nothing to install: one CSS file and one small script, or one React component

Features · 9

  • Follows the algorithm page's listing exactly: Hoare partition, median-of-three pivot, recursion into the smaller side
  • Bars slide when they swap; the range, the pivot line, i and j and the split are drawn as they happen
  • The listing's own code with the running line lit, and a call stack that shows the loop on the bigger side
  • A caption in plain words for every step, plus comparisons, swaps and stack depth against ⌈log₂ n⌉
  • Play, pause, step, scrub and 0.5×–4× speed; a small celebration when the array is sorted
  • Random, sorted, reversed or many-duplicates input from a seed you can replay, or your own values
  • Dark aurora look that also works light; fits a phone, a blog post or a 16:9 slide
  • Plain HTML/CSS/JS and React (Next.js ready) builds
  • Zero dependencies, about 16 KB gzipped (script and styles together)

How to use it

Link the stylesheet and the script once, then mark an empty element with data-quick-sort-animation. It builds the whole player inside it:

HTML
<link rel="stylesheet" href="quick-sort-animation.css" />
<script src="quick-sort-animation.js" defer></script>

<div data-quick-sort-animation data-quick-sort-size="16" data-quick-sort-loop></div>

<!-- your own values, without the extra panels: good for a slide -->
<div
  data-quick-sort-animation
  data-quick-sort-values="7, 2, 9, 4, 3, 8, 1"
  data-quick-sort-inputs="false"
  data-quick-sort-panels="false"
></div>

Options as data attributes (a boolean is on when present, off when it says "false"):

Attribute Default What it does
data-quick-sort-values — Your numbers, separated by commas or spaces (48 at most); replaces the generated array
data-quick-sort-size 16 Bars in a generated array, 2 to 48
data-quick-sort-scenario random random, sorted, reversed or duplicates
data-quick-sort-seed 7 Which generated array: the same seed always draws the same one
data-quick-sort-speed 1 0.25 to 4
data-quick-sort-autoplay on Starts playing on load (never with prefers-reduced-motion)
data-quick-sort-loop off Starts over after the last step
data-quick-sort-inputs on The size and input pickers and the "New input" button
data-quick-sort-panels on The code and call-stack panels

Players added after the page loads: QuickSortAnimation.init(container) — it returns a function that undoes it. To drive one from your own code (a slide clicker, say), build it yourself:

JavaScript
const player = QuickSortAnimation.create(element, { values: [5, 1, 4, 2, 3], autoplay: false });
player.stepForward();
player.seek(20);
player.setValues([9, 8, 7]);
player.destroy(); // the element is given back as it was

The handle also has play, pause, stepBack, reset and frameCount.

With focus anywhere in the player, Space plays or pauses, ← / → step and Home goes back to the start.

Ask about this product

Not sure it fits your project? Ask — the answer comes from this page.

Answers are written by AI from this page and can be wrong. The page itself is what counts.

Changelog

  1. 1.0.0First releaseLatest

    Plain HTML/CSS/JS and React builds of a step-by-step quick sort player (Hoare partition, median-of-three pivot, smaller-side recursion) with pseudocode, call stack, counters, seeded inputs, keyboard and reduced-motion support.

  2. Fixes and new features land behind the same download, which always serves the latest version.

Reviews

No reviews yet

Used it? Be the first to say how it went.

Write a review

How did it work for you? Reviews appear once we have read them.

Your rating
Never shown. Only used if we need to reach you about your review.
0 / 2000

Your name and review are shown on this page; your email is not. See the terms.

  • AnimationSorting

    Merge Sort Animation

    Merge sort, step by step: halves splitting level by level, then two sorted runs merging through one buffer

    Free
  • AnimationSorting

    Insertion Sort Animation

    A card lifted out of the row, bigger bars sliding right underneath, a gap that travels left: insertion sort as shifting, never swapping

    Free
  • AnimationSorting

    Heap Sort Animation

    The array and the binary tree it stands for, side by side: every sink moves both at once, the heap shrinks and the sorted tail locks in

    Free