๐พ ็จๅผ๏ผpaiza.io
// โญ Comparable Enums (Swift 5.3)
// compare according to declaration order (earlier < later)
enum Color: Comparable {
case blue
case green
case white(Double) // โญ associated values must be `Comparable`
case red
case black
}
let colors: [Color] = [
.blue, .black, .red, .white(0.7), .white(0.3), .red
]
print(colors.sorted())
// [.blue, .white(0.3), .white(0.7), .red, .red, .black]