From 923c0d2427f61023eec1ef5e574841cc8f7ad41e Mon Sep 17 00:00:00 2001 From: John Roll Date: Thu, 8 Jan 2026 09:37:44 -0500 Subject: [PATCH] fix: sort WiFi APs with unknown RSSI after known entries APs with unknown signal strength (>= 0.0) were incorrectly sorted before APs with valid negative RSSI values. Now known RSSI entries appear first in descending order, with unknown entries at the bottom. Co-Authored-By: Claude Opus 4.5 --- src/components/wifi_scan.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/components/wifi_scan.rs b/src/components/wifi_scan.rs index 799d5e3..1442c6b 100644 --- a/src/components/wifi_scan.rs +++ b/src/components/wifi_scan.rs @@ -217,9 +217,14 @@ impl WifiScan { self.wifis.push(w.clone()); } } - // -- sort wifi networks by it's signal strength - self.wifis - .sort_by(|a, b| b.signal.partial_cmp(&a.signal).unwrap()); + // -- sort wifi networks by signal strength (known RSSI first, descending) + self.wifis.sort_by(|a, b| { + match (a.signal < 0.0, b.signal < 0.0) { + (true, false) => std::cmp::Ordering::Less, + (false, true) => std::cmp::Ordering::Greater, + _ => b.signal.partial_cmp(&a.signal).unwrap(), + } + }); } fn app_tick(&mut self) -> Result<()> {