title: CoreData fetch() returns objects unordered
body: <p>I have an entity that has a name and for testing purposes I named them in order of most recently added(0) to oldest added object.</p>
  
  <p>When I first launch the app it loads my entities in order(0,1,2...) but if I change the name attribute of any entity the order is all messed up. I use the numberOfRows tableview function to test this as is is called when the tableView is reloaded(correct me if I am wrong):</p>
  
  <pre><code>override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -&gt; Int {
      guard let appDelegate = UIApplication.shared.delegate as? AppDelegate else {return 0}
      let managedContext = appDelegate.managedObjectContext
      let fetchRequest = NSFetchRequest&lt;NSManagedObject&gt;(entityName: "GraphDataSet")
      do {
          graphSetArray.removeAll()
          graphSetArray = try managedContext.fetch(fetchRequest)
      } catch let error as NSError {
          print("Could not fetch. \(error), \(error.userInfo)")
      }
      for i in 0..&lt;graphSetArray.count{
          let set = graphSetArray[(graphSetArray.count-1)-i]
          print("Name: ", set.value(forKeyPath: "name") as? String)
      }
      return graphSetArray.count
  }
  </code></pre>
  
  <p>As far as I understand this empties the Array holding all the entities(although I believe this is pointless as its being set in the next line but I wanted to make sure), then fetches the entities filling the array. I then loop through the array backwards(recent to old) and get the entity of that index and print its name attribute.</p>
  
  <p>This is the console output every time I start the app:</p>
  
  <pre><code>Name:  Optional("0")
  Name:  Optional("1")
  Name:  Optional("2")
  Name:  Optional("3")
  Name:  Optional("4")
  Name:  Optional("5")
  Name:  Optional("6")
  </code></pre>
  
  <p>Here is after I change an entities name value to the same value it was(just for the sake of keeping it in order but technically changing the value and reloading the tableView):</p>
  
  <pre><code>Name:  Optional("5")
  Name:  Optional("4")
  Name:  Optional("1")
  Name:  Optional("3")
  Name:  Optional("0")
  Name:  Optional("2")
  Name:  Optional("6")
  </code></pre>
  
  <p>Not sure why this happens because I am fetching the data the same way every time, and every time I restart the app the order is back to normal. My only theory is that when an entities attribute is changed that the ordering is messed up with no pattern. So I am wondering whether this theory is correct, and if it is then is there any way to stop the ordering from changing?</p>
  
  <p>EDIT: One thing I just noticed is that after it goes out of order, every time after that when I change the value it maintains this unsorted order</p>