sort_results_preserve_selection

Function sort_results_preserve_selection 

Source
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.results and preserves selection by name when possible; otherwise clamps index.

Details:

  • Uses cache-based O(n) reordering when switching between cacheable modes (RepoThenName and AurPopularityThenOfficial).
  • Performs full O(n log n) sort when cache is invalid or for BestMatches mode.
  • Populates both cache orders eagerly after full sort to enable instant mode switching.