nx_sort.nx
buildroot/runtime/nx_sort.nx
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
imports: syscalls.nxsketch_min_heap.nx
imported by: nx_bench_core.nx
structs
| none |
consts
| none |
functions
| 45 | func nx_sort_insertion(arr: *i64, n: i64) -> i64 called by 1: nx_bench_record_samples |
| 67 | func nx_sort_heap(arr: *i64, n: i64) -> i64 |
| 88 | func nx_sort_is_sorted(arr: *i64, n: i64) -> i64 |