// *** before: ***
enum PriorityOld: Int, Comparable {
case low, medium, high
static func <(lhs: PriorityOld, rhs: PriorityOld) -> Bool {
return lhs.rawValue < rhs.rawValue // a raw value invented only for the
//order
}
}
// *** in version 5.3: ***
enum Priority: Comparable {
case low
case medium(urgent: Bool)
case high
}
print(Priority.low < Priority.high) // true
print(Priority.medium(urgent: false) < .medium(urgent: true))
print([Priority.high, .low, .medium(urgent: true)].sorted())
// the order is the order in which the cases are written; associated values
// are compared one after another, and each of them must be Comparable