visionsort
the algorithm beneath.
iris sees because
visionsort taught it to
visionsort treats sorting as a perception problem. iris inherits its eyes.
the algorithm
Most sorting algorithms know nothing about their input. They compare and swap blindly — treating every array as equally unknown.
VisionSort profiles before it sorts. A single forward pass measures entropy, samples disorder, identifies anchors, and maintains a running_surprise signal that updates with every element. When the pass completes, it knows what it's looking at.
iris inherits this pass entirely. The actual sorting never runs — only the perception stage does.
// the signal
running_surprise: f64
// 0.0 → predictable
// 1.0 → chaotic
// updated per element
running_surprise =
running_surprise * 0.995
+ surprise * 0.005
three signals
"iris does not sort. it only perceives. these are the three outputs it takes from visionsort's profiling pass."
running_surprise → stage gating
When surprise stays low, the data is patterned. iris opens its expensive stages — resonance extraction, prediction graph. When high, it routes directly to the code.
disorder sampler → fingerprints
VisionSort samples random index pairs to estimate disorder. iris intercepts that same stream to build 64-bit SimHash fingerprints for the prediction graph.
phase 2 anchors → resonance seeds
VisionSort segments the array using anchor elements. iris reads the anchor spacing as candidate lag values for fast resonance detection on sorted data.
nearsorted.bin
walkthrough
The profiling pass runs. running_surprise holds near 0.02. Autocorrelation peaks at lag=4. Stage gates open fully.
Resonance extraction fires at lag=4. The residual is data[i] wrapping_sub data[i-4]. The residual goes to the internal range coder, squashing the stream into 9,857 bytes.
Final ratio: 405x.
shared principle
VisionSort's core constraint is self-imposed: pay for one read, use it for everything. iris applies the same constraint. Its profiling pass builds the context table, computes autocorrelation at 64 lags, and tracks surprise — all in one forward read.
Perception is cheap and complete before any action begins.
pipeline flow
- → single forward pass
- → entropy & fingerprints
- → stage gates open
- → codec: rANS / range coder
checkout what visionsort is
see the algorithm in motion on its dedicated interactive portal.
visit visionsort.io