How to sort Core Data array based on Date Entered
问题 I have a small Core Data Model which stores an array of Strings (search history). When fetching the Data I'd like to sort by the time created. I currently just have one property in my model called searchHistory is there a way I can use the following code (key: to sort the data or will I need to add a time saved to the model? let request = NSFetchRequest<NSFetchRequestResult>(entityName: entityName) request.sortDescriptors = [NSSortDescriptor.init(key: "", ascending: true)] 回答1: Yes, you need