From ab6abed0c298996faaf4919b0bd0f18bbb903515 Mon Sep 17 00:00:00 2001 From: Alsey Coleman Miller Date: Sun, 26 Mar 2023 15:28:31 -0700 Subject: [PATCH] Fixed `scanResults` sorting --- BluetoothExplorer.swiftpm/Views/CentralList.swift | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/BluetoothExplorer.swiftpm/Views/CentralList.swift b/BluetoothExplorer.swiftpm/Views/CentralList.swift index 11cf2c1..d28fea0 100644 --- a/BluetoothExplorer.swiftpm/Views/CentralList.swift +++ b/BluetoothExplorer.swiftpm/Views/CentralList.swift @@ -16,7 +16,12 @@ struct CentralList: View { var store: Store var scanResults: [Store.ScanResult] { - return store.scanResults.values.sorted(by: { ($0.name ?? $0.id.description) < ($1.name ?? $1.id.description) }) + return store.scanResults + .values + .sorted(by: { $0.id.description < $1.id.description }) + .sorted(by: { ($0.name ?? "") < ($1.name ?? "") }) + .sorted(by: { $0.name != nil && $1.name == nil }) + .sorted(by: { $0.beacon != nil && $1.beacon == nil }) } var body: some View {