Subject-verb inversion in direct speech
In direct speech, if the quotation precedes the reporting verb, the subject and the reporting verb can be inverted:
"I'm so sorry," Maria said / said Maria.
If the subject is long, usually there is inversion:
"Good morning," said the stranger in the black jacket.
But if the subject is a personal pronoun, there is no inversion:
"Good morning," he said.