I was reading the documentation on the Swift programming language, when I came across the following code snippet:
let names = ["Chris", "Alex", "Ewa", "Barry", "Daniella"]
func backwards(s1: String, _ s2: String) -> Bool {
return s1 > s2
}
names.sort(backwards) // ["Ewa", "Daniella", "Chris", "Barry", "Alex"]
What I don't seem to be able to find, is how the >
operator works in this context, I thought it would do something like count the amount of characters and then return a boolean based on that, but with that logic the following snippet should return false:
"CD" > "ABC" // true
Could someone please explain what is going on here?