Sort hosts ignoring case

This commit is contained in:
Davide De Rosa 2018-10-27 16:48:38 +02:00
parent 7abfc544f6
commit b7dc72a5e9
4 changed files with 10 additions and 4 deletions

View File

@ -30,7 +30,7 @@ import SwiftyBeaver
private let log = SwiftyBeaver.self
class ImportedHostsViewController: UITableViewController {
private lazy var pendingConfigurationURLs = TransientStore.shared.service.pendingConfigurationURLs().sorted { $0.normalizedFilename < $1.normalizedFilename }
private lazy var pendingConfigurationURLs = TransientStore.shared.service.pendingConfigurationURLs().sortedCaseInsensitive()
private var parsedFile: ParsedFile?

View File

@ -56,8 +56,8 @@ class OrganizerViewController: UITableViewController, TableModelHost {
}()
func reloadModel() {
providers = service.ids(forContext: .provider).sorted()
hosts = service.ids(forContext: .host).sorted()
providers = service.ids(forContext: .provider)
hosts = service.ids(forContext: .host).sortedCaseInsensitive()
var providerRows = [RowType](repeating: .profile, count: providers.count)
var hostRows = [RowType](repeating: .profile, count: hosts.count)

View File

@ -33,7 +33,7 @@ class WizardHostViewController: UITableViewController, TableModelHost, Wizard {
@IBOutlet private weak var itemNext: UIBarButtonItem!
private let existingHosts: [String] = {
return TransientStore.shared.service.ids(forContext: .host).sorted()
return TransientStore.shared.service.ids(forContext: .host).sortedCaseInsensitive()
}()
var parsedFile: ParsedFile? {

View File

@ -222,3 +222,9 @@ extension URL {
return filename.components(separatedBy: CharacterSet.filename.inverted).joined(separator: URL.illegalCharacterFallback)
}
}
extension Array where Element: CustomStringConvertible {
public func sortedCaseInsensitive() -> [Element] {
return sorted { $0.description.lowercased() < $1.description.lowercased() }
}
}