Sort Descriptor based on ordered to-many relationship : <p>Description of my core data model:</p>

<ul>
<li>Project and Issues entities</li>
<li>Project has an <strong>ordered one-to-many relationship</strong> to Issues named issues</li>
<li>Issue has one-to-one relationship with Project named parentProject</li>
</ul>

<p>Here is my code to obtain issues:</p>

<pre><code>let fetchRequest = NSFetchRequest(entityName: "Issue")
    fetchRequest.predicate = NSPredicate(format: "parentProject CONTAINS[cd] %@", argumentArray: [project])
    fetchRequest.sortDescriptors = [NSSortDescriptor(key: "name", ascending: true)]

    let frc = NSFetchedResultsController(
        fetchRequest: fetchRequest,
        managedObjectContext: dataManager.context,
        sectionNameKeyPath: nil,
        cacheName: nil)

    return arc
</code></pre>

<p>Even though I have all issues from the project object, I prefer to obtain issues using fetched results controller, so they will always be updated and I like the integration with tables. I also like that in navigation controller screen before the projects are displayed using FRC as well.</p>

<p>As you see in the code the Issues are sorted by the name parameter. </p>

<p><strong>However I'd like them to be sorted by the order I keep them in the NSMutableOrderedSet of project.</strong></p>

<p>AFAIK I cannot use NSSortDescriptor with comparator/selector when it's used to Core Data.</p>

<p>Do you know how to do it? Thanks in advance.</p>
