Direct and indirect objects
A direct object is a noun or pronoun that receives the action of a verb direct object answers the question what or who.
John sang the song. John loves Mary.
An indirect object tells to or for whom the action is done.
A sentence cannot have an indirect object if it does not have a direct object.
John sang the song for his mother. John sang the song to the audience.
If there is a preposition, the indirect object goes after the direct object.
She gave the remote control to me.
there is no preposition, the indirect object goes before the direct object.
She gave me the remote control.
When the direct object is a pronoun, the pronoun goes before the indirect object.
She gave it to me.