title: Swift sort array of objects based on boolean value
body: <p>I'm looking for a way to sort a Swift array based on a Boolean value.</p>
  
  <p>I've got it working using a cast to NSArray:</p>
  
  <pre><code>var boolSort = NSSortDescriptor(key: "selected", ascending: false)
  var array = NSArray(array: results)
  return array.sortedArrayUsingDescriptors([boolSort]) as! [VDLProfile]
  </code></pre>
  
  <p>But I'm looking for the Swift variant, any ideas?</p>
  
  <p><strong>Update</strong>
  Thanks to Arkku, I've managed to fix this using the following code:</p>
  
  <pre><code>return results.sorted({ (leftProfile, rightProfile) -&gt; Bool in
      return leftProfile.selected == true &amp;&amp; rightProfile.selected != true
  })
  </code></pre>