code wiki / (root) / nx_sort.nx

nx_sort.nx

buildroot/runtime/nx_sort.nx

3228 B95 linesdepth 5pulls 5 transitivereach 2 importersview sourcekind library
docsdependenciesstructsconstsfunctions

about

nx_sort.nx -- sorting algorithms. Canonical: this is the substrate-wide canonical sort library per [[feedback-no-tool-proliferation-bit-level]]. Provides: - nx_sort_insertion: O(n^2) cache-friendly bubble-style; substrate canonical for small arrays. - nx_sort_heap: O(n log n) in-place; substrate canonical for larger arrays. - nx_sort_is_sorted: invariant check. Other primitives needing a sort MUST `import "nx_sort.nx"` and compose; re-implementing inline is refused per the cardinal. For quicksort variants see nx_quicksort.nx (separate canonical). - Insertion sort: O(n^2) but cache-friendly, good for small arrays. - Heap sort: O(n log n), in-place, uses sketch_min_heap. Pure i64 ascending order. genealogy_id: williams_1964_heap_sort + insertion_sort_folklore lineage_id: in_place_comparison_sort

dependencies 2 imports · 1 importers

syscalls.nx sketch_min_heap.nx nx_sort.nx nx_bench_core.nx

imports: syscalls.nxsketch_min_heap.nx

imported by: nx_bench_core.nx

structs

none

consts

none

functions

45func nx_sort_insertion(arr: *i64, n: i64) -> i64
67func nx_sort_heap(arr: *i64, n: i64) -> i64
88func nx_sort_is_sorted(arr: *i64, n: i64) -> i64