When we enable sorting on the Gallery's Items property, the displayed order of records changes. However, if we try to delete a record by referencing the original collection (unsorted), the record identity may not match because the Gallery is showing a sorted version. This mismatch causes Power Apps to fail to find the record in the sorted collection, resulting in the error.
How to address:
Let's delete from the sorted collection, not the original: Please use the Gallery's AllItems or the sorted collection as the source for deletion, so the record reference matches the displayed data.
Let's use the Gallery's selected item or ThisItem: When deleting, refer to the record as ThisItem inside the Gallery or use the selected item from the sorted collection.
Example deletion formula
Suppose your collection is colReviews and your Gallery's Items property is:
Sort(colReviews, 'Date of review conducted', Descending)
Then, to delete a record from the collection, use:
Remove(colReviews, ThisItem) // This will work because ThisItem refers to the current record in the Gallery, which is sorted.
So when Gallery Items with Sortin enabled, remove by a unique identifier, not by record object, meaining, instead of passing the whole record, remove the item by matching a unique key or ID field that exists in your collection.
Example: RemoveIf(yourEditCollection, ID = ThisItem.ID) //--please note that, if no unique id exist, please create one it will make the life easy.
I am sure some clues I tried to give. If these clues help to resolve the issue brought you by here, please don't forget to check the box Does this answer your question? At the same time, I am pretty sure you have liked the response!