Who gets what?
With geben, schenken, zeigen, bringen and schicken, the thing is usually accusative and the recipient dative. With two noun objects, recipient usually comes first. With two unstressed pronouns, accusative usually comes before dative.
Understand the idea
Some verbs connect a subject with both a thing and a recipient. The thing is commonly accusative and the recipient dative. This pattern appears with geben, schenken, zeigen, bringen and schicken, but each verb should still be learned with its own uses.
Build it step by step
With two ordinary noun phrases, dative commonly precedes accusative in a neutral sentence. Pronouns usually precede noun objects. When both objects are personal pronouns, accusative normally comes before dative. Information structure can change noun order, so these are useful neutral patterns rather than a universal ban on other orders.
See it in a sentence
Ich gebe dem Mann das Buch.
Sie schenkt ihrer Mutter einen Schal.
A useful memory aid
Replace one object at a time. Start with two nouns, then one pronoun, then two pronouns, checking case independently from position.
A common trap
Do not put two pronouns in the same order simply because the original noun phrases used that order. Es ihm is the ordinary two-pronoun sequence.