Sort Pool only when listed as Options
Normally it's PoolGroup who needs sorting.
This commit is contained in:
parent
12597d34b3
commit
89d259e27d
|
@ -192,7 +192,15 @@ extension ProviderPoolViewController: UITableViewDataSource, UITableViewDelegate
|
||||||
}
|
}
|
||||||
let vc = OptionViewController<Pool>()
|
let vc = OptionViewController<Pool>()
|
||||||
vc.title = pool.localizedCountry
|
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.selectedOption = currentPool
|
||||||
vc.descriptionBlock = { $0.areaId ?? "" } // XXX: fail gracefully
|
vc.descriptionBlock = { $0.areaId ?? "" } // XXX: fail gracefully
|
||||||
vc.selectionBlock = {
|
vc.selectionBlock = {
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
import Foundation
|
import Foundation
|
||||||
import TunnelKit
|
import TunnelKit
|
||||||
|
|
||||||
public struct Pool: Codable, Hashable, Comparable, CustomStringConvertible {
|
public struct Pool: Codable, Hashable, CustomStringConvertible {
|
||||||
public enum CodingKeys: String, CodingKey {
|
public enum CodingKeys: String, CodingKey {
|
||||||
case id
|
case id
|
||||||
|
|
||||||
|
@ -105,12 +105,6 @@ public struct Pool: Codable, Hashable, Comparable, CustomStringConvertible {
|
||||||
id.hash(into: &hasher)
|
id.hash(into: &hasher)
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: Comparable
|
|
||||||
|
|
||||||
public static func <(lhs: Pool, rhs: Pool) -> Bool {
|
|
||||||
return lhs.localizedId < rhs.localizedId
|
|
||||||
}
|
|
||||||
|
|
||||||
// MARK: CustomStringConvertible
|
// MARK: CustomStringConvertible
|
||||||
|
|
||||||
public var description: String {
|
public var description: String {
|
||||||
|
|
Loading…
Reference in New Issue