title: What is the difference between sorting an array of strings by localizedCaseInsensitiveCompare and default Comparable?
body: <p>I declared the following array in my playground</p>
  
  <pre><code>var stringArray = ["a","A","@c","&amp;","!","f","G","h"]
  </code></pre>
  
  <p>when I tried to sort it using (since String conforms to <a href="https://developer.apple.com/documentation/swift/comparable" rel="nofollow noreferrer">Comparable</a>) </p>
  
  <pre><code>stringArray = stringArray.sorted(by: { $0 &lt; $1 })
  </code></pre>
  
  <p>I got the following result</p>
  
  <blockquote>
    <p>["!", "&amp;", "@c", "A", "G", "a", "f", "h"]</p>
  </blockquote>
  
  <p>however, if I declared it as </p>
  
  <pre><code>stringArray = stringArray.sorted { $0.localizedCaseInsensitiveCompare($1) == ComparisonResult.orderedAscending }
  </code></pre>
  
  <p>I will get a different result </p>
  
  <blockquote>
    <p>["!", "@c", "&amp;", "A", "a", "f", "G", "h"]</p>
  </blockquote>
  
  <p>The results are not the same.</p>
  
  <p>Why this behavior happens?</p>