diff --git a/Passepartout-iOS/Scenes/Organizer/OrganizerViewController.swift b/Passepartout-iOS/Scenes/Organizer/OrganizerViewController.swift index 7a8723b2..49699eb2 100644 --- a/Passepartout-iOS/Scenes/Organizer/OrganizerViewController.swift +++ b/Passepartout-iOS/Scenes/Organizer/OrganizerViewController.swift @@ -56,7 +56,7 @@ class OrganizerViewController: UITableViewController, TableModelHost { }() func reloadModel() { - providers = service.ids(forContext: .provider) + providers = service.ids(forContext: .provider).sorted() hosts = service.ids(forContext: .host).sortedCaseInsensitive() var providerRows = [RowType](repeating: .profile, count: providers.count) @@ -172,7 +172,7 @@ class OrganizerViewController: UITableViewController, TableModelHost { return } - availableProviderNames = names.sorted { $0.rawValue < $1.rawValue } + availableProviderNames = names.sorted() perform(segue: StoryboardSegue.Organizer.addProviderSegueIdentifier) } diff --git a/Passepartout/Sources/Model/Profiles/ProviderConnectionProfile.swift b/Passepartout/Sources/Model/Profiles/ProviderConnectionProfile.swift index 11bde8ff..7343571d 100644 --- a/Passepartout/Sources/Model/Profiles/ProviderConnectionProfile.swift +++ b/Passepartout/Sources/Model/Profiles/ProviderConnectionProfile.swift @@ -73,7 +73,7 @@ class ProviderConnectionProfile: ConnectionProfile, Codable, Equatable { } func sortedPools() -> [Pool] { - return infrastructure.pools.sorted { $0.name < $1.name } + return infrastructure.pools.sorted() } private func validateEndpoint() { diff --git a/Passepartout/Sources/Services/Infrastructure.swift b/Passepartout/Sources/Services/Infrastructure.swift index 30af0b36..47dc95df 100644 --- a/Passepartout/Sources/Services/Infrastructure.swift +++ b/Passepartout/Sources/Services/Infrastructure.swift @@ -27,12 +27,16 @@ import Foundation import TunnelKit struct Infrastructure: Codable { - enum Name: String, Codable { + enum Name: String, Codable, Comparable { case pia = "PIA" var webName: String { return rawValue.lowercased() } + + static func <(lhs: Name, rhs: Name) -> Bool { + return lhs.webName < rhs.webName + } } struct Defaults: Codable { diff --git a/Passepartout/Sources/Services/Pool.swift b/Passepartout/Sources/Services/Pool.swift index 3e1b9067..004b3778 100644 --- a/Passepartout/Sources/Services/Pool.swift +++ b/Passepartout/Sources/Services/Pool.swift @@ -26,7 +26,7 @@ import Foundation import TunnelKit -struct Pool: Codable, CustomStringConvertible { +struct Pool: Codable, Comparable, CustomStringConvertible { enum CodingKeys: String, CodingKey { case id @@ -68,7 +68,13 @@ struct Pool: Codable, CustomStringConvertible { addrs.insert(hostname, at: 0) return addrs } + + // MARK: Comparable + static func <(lhs: Pool, rhs: Pool) -> Bool { + return lhs.name < rhs.name + } + // MARK: CustomStringConvertible var description: String {