Sort Pool only when listed as Options

Normally it's PoolGroup who needs sorting.
This commit is contained in:
Davide De Rosa 2019-04-10 15:31:14 +02:00
parent 12597d34b3
commit 89d259e27d
2 changed files with 10 additions and 8 deletions

View File

@ -192,7 +192,15 @@ extension ProviderPoolViewController: UITableViewDataSource, UITableViewDelegate
}
let vc = OptionViewController<Pool>()
vc.title = pool.localizedCountry
vc.options = groupPools
vc.options = groupPools.sorted {
guard let lnum = $0.num, let ln = Int(lnum) else {
return true
}
guard let rnum = $1.num, let rn = Int(rnum) else {
return false
}
return ln < rn
}
vc.selectedOption = currentPool
vc.descriptionBlock = { $0.areaId ?? "" } // XXX: fail gracefully
vc.selectionBlock = {

View File

@ -26,7 +26,7 @@
import Foundation
import TunnelKit
public struct Pool: Codable, Hashable, Comparable, CustomStringConvertible {
public struct Pool: Codable, Hashable, CustomStringConvertible {
public enum CodingKeys: String, CodingKey {
case id
@ -105,12 +105,6 @@ public struct Pool: Codable, Hashable, Comparable, CustomStringConvertible {
id.hash(into: &hasher)
}
// MARK: Comparable
public static func <(lhs: Pool, rhs: Pool) -> Bool {
return lhs.localizedId < rhs.localizedId
}
// MARK: CustomStringConvertible
public var description: String {