ludic/tools
Orkuncakilkaya 4aa2012231
Some checks are pending
docs / build-and-deploy (push) Waiting to run
feat(stdlib): sorting toolkit — sort_by/sort_desc_by/sort_with + stable merge sort (#11)
Grow List sorting from a numeric-only insertion sort into a small,
game-friendly toolkit that sorts records and query results by a key or a
full comparator, stably and in O(n log n).

- List.sort_by(s, keyfn)      ascending by a key (draw order, price)
- List.sort_desc_by(s, keyfn) descending (leaderboards)
- List.sort_with(s, cmpfn)    full cmp(a,b)->int comparator (multi-field)

Comparators/keys are passed as named top-level functions rather than
lambdas, so the toolkit ships without waiting on closures (#1).

Engine: a stable bottom-up merge sort. emit_takeright is the single
place stability is decided ("take the right run's head only on a strict
win" -> equal keys keep prior order). List.sort becomes a hybrid:
insertion sort for n<32, merge sort above; both stable, so output is
unchanged. Key functions must return an integer-ish type; record slices
hold pointer elements, so the key/comparator receives the record pointer.

Tests: selfhost/tests/sort.ludic (scalar large-n, sort_by, sort_desc_by,
stability, sort_with). Docs: list-sort_by/desc_by/with + updated
list-sort. All suites green (28 self-host / 46 test / 29 test-tools);
reseeded, C-free bootstrap fixpoint holds.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-08-30 11:39:26 +03:00
..
docgen feat(stdlib): DateTime format/parse + simulated Clock — completes #9 2026-08-30 03:51:48 +03:00
editors feat(stdlib): 2D Vector type + Vector.* namespace (issue #25) 2026-08-30 02:09:38 +03:00
git-hooks Baseline: Ludic compiler + toolchain, Phase 1 syntax fixes complete 2026-08-27 15:15:35 +03:00
ludic-tools feat(stdlib): DateTime format/parse + simulated Clock — completes #9 2026-08-30 03:51:48 +03:00
ludic-web Baseline: Ludic compiler + toolchain, Phase 1 syntax fixes complete 2026-08-27 15:15:35 +03:00
x feat(stdlib): sorting toolkit — sort_by/sort_desc_by/sort_with + stable merge sort (#11) 2026-08-30 11:39:26 +03:00
atlas.ludic refactor(lang): rename the ptr/ptrs types to pointer/pointers 2026-08-30 01:58:54 +03:00
check-docs.py refactor(lang): rename the fn keyword to function 2026-08-30 01:43:22 +03:00
check-vocabulary.py Phase 8b: modern names for the raw-memory and OS/IO primitives 2026-08-28 02:55:24 +03:00
test-grammar.js Baseline: Ludic compiler + toolchain, Phase 1 syntax fixes complete 2026-08-27 15:15:35 +03:00
test-lsp.py refactor(lang): rename the fn keyword to function 2026-08-30 01:43:22 +03:00