Sort the trashed items by ID to avoid deadlocks.