AI Navigate

Sorting algorithms

Simon Willison's Blog / 3/12/2026

💬 OpinionTools & Practical UsageModels & Research

Key Points

  • The author created interactive animated demos of the most common sorting algorithms using Claude, then extended them with Python's timsort for comparison.
  • They show how Claude can clone GitHub repos and reference real CPython source files (Objects/listsort.txt and Objects/listobject.c) to implement timsort in the demos.
  • They added a "run all" feature that runs multiple algorithm visualizations in a grid at once, with controls like SIZE and SPEED and UI elements like Stop, Shuffle, and Back to single.
  • The final visualization, titled "All algorithms racing," displays seven algorithms with live metrics (Comparisons, Swaps, Pivot, Sorted) across cards and a legend, illustrating how performance differs.
  • The post also notes prompts and iterations (e.g., color scheme tweaks) and mentions a cross-check by GPT-5.4 Thinking on Claude's implementation.
Sponsored by: Postman — Every API your agents depend on, mapped and monitored. See what's new

11th March 2026 - Link Blog

Sorting algorithms. Today in animated explanations built using Claude: I've always been a fan of animated demonstrations of sorting algorithms so I decided to spin some up on my phone using Claude Artifacts, then added Python's timsort algorithm, then a feature to run them all at once. Here's the full sequence of prompts:

Interactive animated demos of the most common sorting algorithms

This gave me bubble sort, selection sort, insertion sort, merge sort, quick sort, and heap sort.

Add timsort, look up details in a clone of python/cpython from GitHub

Let's add Python's Timsort! Regular Claude chat can clone repos from GitHub these days. In the transcript you can see it clone the repo and then consult Objects/listsort.txt and Objects/listobject.c. (I should note that when I asked GPT-5.4 Thinking to review Claude's implementation it picked holes in it and said the code "is a simplified, Timsort-inspired adaptive mergesort".)

I don't like the dark color scheme on the buttons, do better

Also add a "run all" button which shows smaller animated charts for every algorithm at once in a grid and runs them all at the same time

It came up with a color scheme I liked better, "do better" is a fun prompt, and now the "Run all" button produces this effect:

Animated sorting algorithm race visualization titled "All algorithms racing" with controls for SIZE (50) and SPEED (100), Stop and Shuffle buttons, and a "Back to single" button. A legend shows Comparing (pink), Swapping (orange), Pivot (red), and Sorted (purple) indicators. Seven algorithms race simultaneously in card panels: Bubble sort (Sorting… — Comparisons: 312, Swaps: 250), Selection sort (Sorting… — Comparisons: 550, Swaps: 12), Insertion sort (Sorting… — Comparisons: 295, Swaps: 266), Merge sort (#3 — Comparisons: 225, Swaps: 225), Quick sort (#2 — Comparisons: 212, Swaps: 103), Heap sort (Sorting… — Comparisons: 358, Swaps: 203), and Timsort (#1 — Comparisons: 215, Swaps: 332). Finished algorithms (Timsort, Quick sort, Merge sort) display fully sorted purple bar charts and are highlighted with purple borders.

Posted 11th March 2026 at 10:58 pm

This is a link post by Simon Willison, posted on 11th March 2026.

algorithms 20 computer-science 14 javascript 744 sorting 6 ai 1899 explorables 29 generative-ai 1683 llms 1649 claude 259 vibe-coding 75

Monthly briefing

Sponsor me for $10/month and get a curated email digest of the month's most important LLM developments.

Pay me to send you less!

Sponsor & subscribe