OP's second version is standard usage, which is why @Barrie calls it the "uninverted form". But note he's only referring to inversion of subject - verb (the object here being the quoted speech).
The most common structure for English sentences is subject - verb - object...
Joe said "The sky is blue".
...and the most common "sentence inversion" is object - verb subject...
"The sky is blue," said Joe.
There's nothing "ungrammatical" about object - subject - verb as in OP's first version, which may be prefered for stylistic reasons in some contexts. And least common, verb - subject - object is still perfectly valid English too...
Said Joe, "The sky is blue".
...but you'd normally only see this in poetic or other stylised writing, rather than in speech.