I declared the following array in my playground
var stringArray = ["a","A","@c","&","!","f","G","h"]
when I tried to sort it using (since String conforms to Comparable)
stringArray = stringArray.sorted(by: { $0 < $1 })
I got the following result
["!", "&", "@c", "A", "G", "a", "f", "h"]
however, if I declared it as
stringArray = stringArray.sorted { $0.localizedCaseInsensitiveCompare($1) == ComparisonResult.orderedAscending }
I will get a different result
["!", "@c", "&", "A", "a", "f", "G", "h"]
The results are not the same.
Why this behavior happens?