Indirect object pronoun before direct object
Both sentences are correct and present an indirect object.
- The most common way to introduce an indirect object is following the pattern of the first sentence.
Subject + Transitive Verb + Indirect Object + Direct Object.
- The other way is also the pattern of the 2nd sentence you posted.
Subject + Transitive Verb + Indirect Object + to/for + Object of the preposition (which is also the indirect object)
NOTE: Sometimes, the indirect object will follow a preposition like to or for.