title: Sorting nsfetchedresultscontroller
body: <p>I have this structure in a entity of core data:</p>
  
  <pre><code>ID    Region    SubRegion   SubRegionID    CellText
  1      Face      Mouth         2             something
  2      Face      Eyes          1             ...
  3      Face      Nose          4             ...
  ...
  </code></pre>
  
  <p>But I want my tableview (nsfetchedresultscontroller) sorted this way:</p>
  
  <p>Inside each section: cells sorted by ID property
  Sections in tableView: SubRegion names but sorted by SubRegionID.</p>
  
  <p>How can I achieve this? By now I'm doing this but I don't know is the best practice to sort section titles by subregionID:</p>
  
  <pre><code>NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
  NSEntityDescription *entity = [NSEntityDescription 
                                 entityForName:@"DataBase" inManagedObjectContext:context];
  [fetchRequest setEntity:entity];
  
  NSPredicate *requestPredicate = [NSPredicate predicateWithFormat:[NSString stringWithFormat:@"(Region like '%@')", @"Face"]];
  [fetchRequest setPredicate:requestPredicate];
  
  NSSortDescriptor *ID = [[NSSortDescriptor alloc] 
                            initWithKey:@"ID" ascending:YES];
  
  [fetchRequest setSortDescriptors:[NSArray arrayWithObjects: ID, nil]];
  
  [fetchRequest setFetchBatchSize:10];
  
  fetchedResultsController  = 
  [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest 
                                      managedObjectContext:context sectionNameKeyPath:@"SubRegion" 
                                                 cacheName:nil];
  
  fetchedResultsController.delegate = self;
  </code></pre>
  
  <p>Thanks for your time!</p>