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.