Skip to content

Commit

Permalink
Sort CoreData objects by ID
Browse files Browse the repository at this point in the history
  • Loading branch information
colemancda committed Aug 30, 2023
1 parent 079c8d1 commit d1aa943
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Sources/CoreDataModel/NSFetchRequest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@ public extension FetchRequest {
let fetchRequest = NSFetchRequest<ResultType>(entityName: entity.rawValue)
fetchRequest.predicate = predicate?.toFoundation()
fetchRequest.fetchLimit = fetchLimit
fetchRequest.sortDescriptors = sortDescriptors.map {
var sortDescriptors = sortDescriptors.map {
NSSortDescriptor(key: $0.property.rawValue, ascending: $0.ascending)
}
sortDescriptors.append(NSSortDescriptor(key: NSManagedObject.BuiltInProperty.id.rawValue, ascending: true))
fetchRequest.sortDescriptors = sortDescriptors
return fetchRequest
}
}
Expand Down

0 comments on commit d1aa943

Please sign in to comment.