The captain of a sinking Indonesian ferry managed to steer his ship onto a reef to enable the evacuation of more than 100 passengers, but 31 people drowned as the vessel floundered in stormy seas, officials said on Wednesday.