title: How to sort lines of a string in Swift?
body: <p>I have a textView where I enter text, I would like to programmatically sort lines (intended here as chunks of text separated by a newline). For example:</p>
  
  <pre><code>Bravo
  27
  Charlie
  Zulu
  delta
  012
  Alfa
  bravo
  Delta
  </code></pre>
  
  <p>I'm trying to convert the tex to an array, then sort the array and then joying the array in a new string. Unfortunately I get unexpected results, for example words with capital letters are grouped at the beginning of the list, the ones with lowercase are listed at the end. </p>
  
  <p>This is the code I'm using:</p>
  
  <pre><code>let newStr = (the field) // pseudocode
  
  let strArray : [String] = newStr.componentsSeparatedByString("\n")
  let newArray = strArray.sort { $0 &lt; $1 }
  newStr = newArray.joinWithSeparator("\n")
  
  (the field) = newStr // pseudocode
  </code></pre>
  
  <p>EDIT: the result I would like to get, would be to have a sorted list taking into account local settings. In my case, for example, would be:</p>
  
  <pre><code>012
  27
  Alfa
  bravo
  Bravo
  Charlie
  delta
  Delta
  Zulu
  </code></pre>