Using Swift 4.2, I'm trying to figure out sorting my objects that contain two dates, such that the most recent object is first in the array.
I'm experimenting with the following, but it fails due to:
Binary operator '>=' cannot be applied to two '(Date?, Date?)' operands
.
let sortedSignComments = signComments.sorted(by: {
guard let serverDate0 = $0.serverLastUpdated else { return false }
guard let serverDate1 = $1.serverLastUpdated else { return false }
guard let clientDate0 = $0.clientLastUpdated else { return false }
guard let clientDate1 = $1.clientLastUpdated else { return false }
let lhs = (formatter.date(from: serverDate0), formatter.date(from: clientDate0))
let rhs = (formatter.date(from: serverDate1), formatter.date(from: clientDate1))
return lhs >= rhs
})