title: Core data sort objects by date not producing expected output
body: <p>I am trying to display objects based on the time they were created. Each object is a NSManagedObject with a dateCreated property. I wrote the code below:</p>
  
  <pre><code>NSFetchRequest * request = [[NSFetchRequest alloc] init];
  NSEntityDescription *e = [NSEntityDescription entityForName:@"MyObject" inManagedObjectContext:context];
  request.sortDescriptors = @[[NSSortDescriptor sortDescriptorWithKey:@"dateCreated" ascending:NO]];
  request.entity = e;
  NSError * error;
  NSArray* result = [context executeFetchRequest:request error:&amp;error];
  for (MyObject* object in result) {
       NSLog(@"%@", @([object.dateCreated timeIntervalSince1970]));
  }
  </code></pre>
  
  <p>and here is the output:</p>
  
  <pre><code>2018-03-06 08:55:06.591 1520326503.972214
  2018-03-06 08:55:06.591 1520326503.995906
  2018-03-06 08:55:06.592 1520326504.012891
  2018-03-06 08:55:06.592 1520326504.002804
  2018-03-06 08:55:06.592 1520326503.989189
  2018-03-06 08:55:06.592 1520326504.009239
  2018-03-06 08:55:06.592 1520326503.964928
  2018-03-06 08:55:06.592 1520326503.968894
  </code></pre>
  
  <p>i.e. there are not sorted. I checked that the dates output are correct (i.e. as expected) but the order is not. If I sort by another key (e.g. name) code is fine so I thought the request was correctly being set. Also, the following code correctly sorts the resulting array:</p>
  
  <pre><code>result = [result sortedArrayUsingComparator:^NSComparisonResult(MyObject*  _Nonnull obj1, MyObject*  _Nonnull obj2) {
      return [obj2.dateCreated compare:obj1.dateCreated];
  }];
  </code></pre>