Assume that a passenger on a cruise ship has something like a heart attack and it's quite clear that they're dead (any attempts at reanimation failed for a reasonable amount of time). Assume the ship is either docked at a harbor or will reach a harbor within a few days.
The harbor is not in the country where the trip started or will end.
If it's important to limit the scope of the question: assume the trip started in an EU country and the ship is currently outside of EU territory.
What happens to the body?
Will the body be buried in the foreign country or will it be transported back to the home country?
Will the ship itself transport the body?
The reason I ask is that I once read that cruise ships must be equipped with a morgue for at least 2 bodies, and when I was on a cruise ship I noticed that a large number of passengers were elderly and there were several medical emergencies during the trip. Let's say it got me wondering...
I also read What happens when you die while traveling internationally? but it only deals with policies of countries. As far as I know a passenger on a cruise ship (even one docked at harbor) is still in international waters and technically only enters a country when they leave the ship or even cross a certain line in the harbor.