v6: SortCore step-generator engine, 4 new algorithms, complexity profiler - #2
Open
Sebby1770 wants to merge 1 commit into
Open
v6: SortCore step-generator engine, 4 new algorithms, complexity profiler#2Sebby1770 wants to merge 1 commit into
Sebby1770 wants to merge 1 commit into
Conversation
… profiler (v6) - sorting-core.js: all 14 sorting algorithms as pure step generators (browser global SortCore + Node CJS), one implementation shared by the page, the tests, and the profiler - New algorithms: Comb, Gnome, Cycle (minimal writes), simplified TimSort - Complexity Profiler: benchmarks every algorithm at n=16..512, log-log chart + fitted empirical growth exponent vs theoretical class - SortRunner now animates the op stream instead of hardcoding algorithms - 47 sorting unit tests incl. stability proofs and cycle write bound - SW cache v6, README/CHANGELOG updates Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this does
Rebuilds the Sort Lab's engine around a single testable core and adds an empirical complexity lab on top of it.
sorting-core.js— one implementation, three consumersAll sorting logic now lives in a dependency-free module of pure step generators (
SortCorein the browser, CJS in Node — same pattern aspathfinding-core.js). Each algorithm yields a stream of ops (compare/swap/write/touch/counts/mark/narrate/gap/digitExp), and:SortRunneranimates the stream (metrics, sound, heatmap, narration, step mode all preserved — ~450 lines of duplicated per-algorithm animation code deleted),Four new algorithms (10 → 14)
All four are wired into the select, race mode, tournament, quiz, learning cards, and profiles.
📈 Complexity Profiler
One click benchmarks all 14 algorithms at n = 16…512 on the current dataset shape, draws a log-log chart, and least-squares-fits each line's slope — the measured exponent k in O(nᵏ) — next to the theoretical class. Verified in-browser: radix/counting measure n^1.00, merge/heap/tim land at n^1.2–1.3, bubble at ~n^2.
Tests — 47 new (66 total, still zero dependencies)
node --test tests/sorting.test.jscovers: correctness for every algorithm on 8 dataset shapes + edge cases, input non-mutation, stability proofs for the 8 stable sorts (tagged-key trick), cycle sort's ≤ n write bound and 0-writes-on-sorted property, exact bubble counts on reversed input, and exponent-estimator checks that separate quadratic from linearithmic growth.Also
sorting-core.jsVerification
🤖 Generated with Claude Code