sort_by_key

std.stats.sort_by_key · Level L3

Reorder the values by the stable order of the keys: ArgSort the keys, Cast the positions to indices, Gather the values.

values[argsort(keys)]

Signature

sort_by_key(keys: f64[n], values: f64[n]) → f64[n]

Structure

The function as NOVA stores it: one box per input, operation and output, and arrows that carry values. A double border marks another library function this one runs — called once, or by Scan once per element; select it to open that function.

keysf64[n]valuesf64[n]ArgSortorderCastidxGathersortedsortedf64[n]
  • input
  • operation
  • constant
  • call
  • output

Verification

  • Signature proven by NOVA’s shape solver, for every size.
  • Equal to the reference values[np.argsort(keys, kind="stable")] in exact rational arithmetic, on all 40 test cases.
  • All 137 float64 results are exact: the error is zero.
  • Interpreter and NumPy backend return bit-identical results.
Accuracy in detail
correctly rounded (the float64 nearest the exact value)
100%
bit-equal to the NumPy formula in float64
100%
largest error, in units in the last place
0

Identity

Calls
—
Called by
—
sha256:7708d4fe67fcb01fecf292e930a45fa2389f90b1bdc8af53364e5331a1622c08

The semantic hash of the graph. It changes when the program changes, and never when only its documentation does.

Control handle

Symbol
Ω:std.stats.sort_by_key · Ω:sort_by_key
Pins
sha256:ddb7c7125d79c18bb76756e3d559f2036d0c9a8a33d6de5312d6bf115cac250ethis graph alone
Evidence
sha256:14995ff971c3448a2b1512ecd6263393b5480797b42943cfbaf57ed36be82082the hash of its verification record
Needs
no capability: a pure function

Through NOVA’s control layer, the symbol launches this function only while the program still matches what it pins: a change to this graph, or to any graph it reaches, needs a migration first.