title: NSFetchedResultsController: sort descriptors and sections
body: <p>I have a core data model like so...</p>
  
  <pre><code>[Country] &lt;---&gt;&gt; [League] &lt;---&gt;&gt; [Match]
  </code></pre>
  
  <p>And I'm using an <code>NSFetchedResultsController</code> to display the <code>Matches</code> into a <code>UITableView</code>.</p>
  
  <p>I've done this a million times before but for some reason the sections are going wrong and I can't work out why.</p>
  
  <p>I have created the sort descriptors like so...</p>
  
  <pre><code>NSSortDescriptor *countrySD = [NSSortDescriptor sortDescriptorWithKey:@"league.country.name" ascending:YES];
      NSSortDescriptor *leagueSD = [NSSortDescriptor sortDescriptorWithKey:@"league.name" ascending:YES];
      NSSortDescriptor *dateSD = [NSSortDescriptor sortDescriptorWithKey:@"startDate" ascending:YES];
      request.sortDescriptors = @[countrySD, leagueSD, dateSD];
  </code></pre>
  
  <p>First I want to check I have put these in the correct order. This should first sort by the <code>country.name</code> then sort by the <code>league.name</code> and then sort by the <code>startDate</code>.</p>
  
  <p>i.e.</p>
  
  <ol>
  <li>Anything in <code>Albania</code> should come before anything in <code>Spain</code>.</li>
  <li>In a single country, anything in <code>League 1</code> should come before anything in <code>League 2</code>.</li>
  <li>In a single league all the matches should be displayed in <code>startDate</code> order with the earliest first.</li>
  </ol>
  
  <p>Then I'm creating the <code>NSFRC</code> with this...</p>
  
  <pre><code>_fetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:request managedObjectContext:self.moc sectionNameKeyPath:@"league.leagueID" cacheName:nil];
  </code></pre>
  
  <p>So this should group the table by matches with different <code>league.leagueID</code> values.</p>
  
  <p>It should be something like...</p>
  
  <pre><code>Albania - League 1
      12:00
      13:00
  Albania - League 2
      09:00
      14:00
  France - League 1
      09:00
  Spain - A League
      08:00
      12:00
  Spain - B League
      09:00
  </code></pre>
  
  <p>It isn't working though. I get multiple headers for the same league. Some of the matches appear under the wrong header etc...</p>
  
  <p>I've checked the values (NSLogged) of the matches appearing under the wrong league and they actually have the correct league. So even though they have <code>Spain - A League</code> they are appearing under <code>France - League A</code> (for example).</p>
  
  <p>Any idea how I can fix this?</p>