title: Swap array values in Swift
body: <p>I have <strong>3 elements</strong> in the array which contains <strong>strings</strong> and <strong>numbers</strong>(as strings)</p>
  
  <p>for eg, array contain elements like</p>
  
  <pre><code> var elementArray:NSArray //"3","2","1","abc"
  </code></pre>
  
  <p>After sorting it becomes</p>
  
  <pre><code>var sortedArray = //"1","2","3","abc"
  </code></pre>
  
  <p>I want to make a string as first and the numbers in the last.</p>
  
  <p>Expected output should be </p>
  
  <pre><code>var sortedArray = //"abc","1","2","3"
  </code></pre>
  
  <p>How can I swap the array elements.</p>
  
  <p>Note that if array has multiple strings and numbers(strings like <code>"1"</code>,<code>"2"</code>). The strings(words or characters) should be come first and the numbers (which should be in ascending order)comes last.</p>
  
  <p>so far I tried this.</p>
  
  <pre><code> var sortedArray:NSArray = array.sortedArrayUsingComparator({(item1:AnyObject!, item2:AnyObject!) -&gt; NSComparisonResult in
              let comparisonOptions:NSStringCompareOptions =
              NSStringCompareOptions.CaseInsensitiveSearch |
                  NSStringCompareOptions.NumericSearch |
                  NSStringCompareOptions.WidthInsensitiveSearch |
                  NSStringCompareOptions.ForcedOrderingSearch;
  
              var str1:String = (item1 as String)
              var str2:String = (item2 as String)
  
              return str1.compare(str2, options: comparisonOptions, range: str1.startIndex ..&lt; str1.endIndex, locale: NSLocale.currentLocale())
          })
  </code></pre>
  
  <p>which returns result as <code>"1","2","3","abc"</code>.</p>
  
  <p>But the expected output should be <code>"abc","1","2","3"</code>. How can I exchange object in the array.</p>