title: How to sort a fetch in Core Data
body: <p>I'm doing a fetch of data to show it in a UITableView, I do the fetch but I want to sort them by date of creation or by any sort method.</p>
  
  <p>Here is the method:</p>
  
  <pre><code>-(NSArray *) lesStations {
  
  NSManagedObjectContext *moc = [[AppDelegate sharedAppDelegate]managedObjectContext];
  
  NSFetchRequest *fetch = [[NSFetchRequest alloc] init];
  NSEntityDescription *entity =  [NSEntityDescription entityForName:@"Station" inManagedObjectContext:moc];
  
  [fetch setEntity:entity];
  NSError *error;
  
  NSArray *result = [moc executeFetchRequest:fetch error:&amp;error];
  
  if (!result) {
      return nil;
  }
  
  return result;
  
  }
  </code></pre>