pub fn order_entries(entries: &[Entry]) -> Vec<u32>Expand description
Returns indices into entries, ordered by attention rank then by path.
Returns a flat Vec<u32> of indices rather than reordered entries: the caller
already holds the paths, and re-sending them would copy every string across the
boundary for no gain.
§Paths must be sorted by the caller, and that is not optional
This sorts by rank only. The JS twin sorts by rank and path, so the two agree only when the caller has already sorted by path. Passing unsorted entries is silent: the WASM returns a plausible order that differs from the JS one only in ties, where nothing looks wrong.
This was a real divergence, caught by a parity test that fed entries in
non-alphabetical order. Two ways to close it were possible – move the path
comparison here, or require sorted input – and requiring sorted input was
chosen because sorting paths in Rust would mean copying every path string across
the boundary, which is the ~302 KB js-sys problem AGENTS.md warns about, for
the sake of a tie-break the caller can do for free while it already holds the
paths. order_entries_js documents the requirement at the boundary.