pub fn sort_results_preserve_selection(app: &mut AppState)Expand description
What: Apply the currently selected sorting mode to app.results in-place.
Inputs:
app: Mutable application state (results,selected,input,sort_mode)
Output:
- Sorts
app.resultsand preserves selection by name when possible; otherwise clamps index.
Details:
- Uses cache-based O(n) reordering when switching between cacheable modes (
RepoThenNameandAurPopularityThenOfficial). - Performs full O(n log n) sort when cache is invalid or for
BestMatchesmode. - Populates both cache orders eagerly after full sort to enable instant mode switching.