Per layer only min(candidates, residents) victims can pair; select_nth + a sort of those, with (value, expert) as the total order (= the earlier stable sort), and the
per-layer vectors are reused. Test: 40 random usage/resident cases with ties against the kept reference implementation, identical swaps and order for max_swaps 1/5/96/4096.
Micro timing (laptop, synthetic 46 % resident): 580 -> 480 us per call; one call per adaptation (every 4th round). Not measured on the 5090.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>