There is no rule that specifies that only the direct object comes first.
Anna gave me a book.
Anna gave a book to me.
both sentences are equally correct as the indirect object is free to be located after the verb or after the direct object, using a preposition.