title: Swift: Sort Array by sort descriptors
body: <p>I am using coredata so I need sort descriptors for my entities</p>
  
  <p>For example, a Coordinate-entity has this class func:</p>
  
  <pre><code>class func sortDescriptors() -&gt; Array&lt;NSSortDescriptor&gt;
  {
      return [NSSortDescriptor(key: "sequence", ascending: true)]
  }
  </code></pre>
  
  <p>I am using this when doing fetch-requests to CoreData like this:</p>
  
  <pre><code>var request = NSFetchRequest(entityName: entityName)
  
  request.sortDescriptors = T.sortDescriptors()
  </code></pre>
  
  <p>However, when I have an array of coordinates as a property on another coredata object, this is an NSSet (I.e. unsorted)</p>
  
  <p>To solve this, I am returning the coordinates like this:</p>
  
  <pre><code>return NSArray(array: coordinates!).sortedArrayUsingDescriptors(Coordinate.sortDescriptors()) as? Array&lt;Coordinate&gt;
  </code></pre>
  
  <p>Which feels ugly, to use an NSArray just to get the <code>sortedArrayUsingDescriptors</code>-method. Is there a similar way to do this directly on a Swift-array, I.e. <code>Array&lt;Coordinate&gt;</code> by using sort descriptors?</p>
  
  <p>Thank you!</p>