I have this struct:
struct HostModel {
var hostName: String?
var hostPhoneNumber: String?
var hostEmail: String?
}
var hosts = [HostModel]()
This is populated by downloading from Firebase Database.
//Getting the data....
let hostData = HostModel(hostName: dict["hostName"] as? String, hostPhoneNumber: dict["hostPhoneNumber"] as? String, hostEmail: dict["hostEmail"] as? String)
self.hosts.append(hostData)
All is fine until I'm trying to sort the struct:
self.hosts.sorted { (lhs, rhs) -> Bool in
return lhs.hostName < rhs.hostName
}
This gives the error:
Binary operator '<' cannot be applied to two 'String?' operands