Compare 2 strings

 Problem

I have two strings and want to compare them lexicographically (what comes first in a "dictionary").



 Recipe


// String literals
let s1 = "Hello World"
let s2 = "Hello Guys"
 
// Compare the 2 strings
// lexicographically

if s1<s2 {
    print("S1 comes before S2")
}
else {
    print("S1 comes after S2")
}
				

Heard the news?

The Swift Cookbook for Swift 3 is at last here! For iBooks, Kindle and Paperback.
Hurry up - and Check it out! ;-)

 

 Playground