How does the Reminders app implement manual sort order?

Does the Reminders app use Core Data with CloudKit behind the scenes? I would like to know what approach is used to allow for re-ordering items and how conflicts are handled when move operations are done from multiple offline devices.

It's hard to tell if Apple uses Core Data and CloudKit, but my guess is that they do. I'm not really sure what you mean by "reordering items" but I can tell you that using Core Data and CloudKit is very straightforward, just search for NSPersistentCloudKitContainer for using CloudKit and for Core Data I highly recommend you to watch the following tutorials; they're great.

Swiftful Thinking:
https://www.youtube.com/watch?v=BPQkpxtgalY

@fsdolphin A given reminder can be dragged and placed in a different position when using "Sort By Manual". This functionality is enabled when adding onMove inside a List. What I find tricky is how to handle the case when changes are made from multiple offline devices.

For example, if I add a sortOrder field to each item, I would end up with duplicate values when adding a third item with sortOrder max(sortOrder) + 1 = 2 + 1 = 3 on the first offline device, and a different item with a sortOrder of 3 on the second offline device.

@fsdolphin https://www.youtube.com/watch?v=Rh05puZsh6o&t=529s is an example of how to manage manual sort order locally. (each item basically has a arrayPosition field) When adding CloudKit, I am not sure how to handle conflicts.

Example:

On the first device, move "Item 1" to the back: "Item 2" (sortOrder = 0), "Item 3" (sortOrder = 1), "Item 1" (sortOrder = 2)

On the second device, move "Item 3" to the front: "Item 3" (sortOrder = 0), "Item 1" (sortOrder = 1), "Item 2" (sortOrder = 2)

When syncing, the result should be: "Item 3", "Item 2", "Item 1" as if the move operations where done in chronological order

How does the Reminders app implement manual sort order?
 
 
Q