The part of the clause between two parts of the verb (the second and the last position) is called the midfield. All the parts of the
sentence except for the verb can change their position and can occupy either the first position or the midfield. As for the word order
in the midfield the rule "the short precedes the long" can be used in most of the situations. That means:

1) a pronoun precedes a noun;
 position 1     position 2     midfieldlast position 
 Ichhabeihm das Buch     gezeigt.

2) the order of the nouns: the noun in the nominative case – the noun in the dative case – the noun in the accusative case – the
noun in the genitive case;
 position 1     position 2     midfieldlast position 
 GesternhatRichard dem Lehrer das Buch seines Freundes     gezeigt.

3) the order of the pronouns: the pronoun in the nominative case – the pronoun in the accusative case – the pronoun in the dative
 Position 1     Position 2     midfield     last position 
 Gesternhater es ihmgezeigt.

4) the order of the adverbial modifiers (mostly): temporal (When?) – causal (Why?) – modal (How?) – local (Where?) → te-ca-mo-lo;
 Position 1     Position 2     midfieldlast position 
 Ichmöchteheute wegen des Regens nicht zu Fuß in den Supermarkt     gehen.

5) Adverbial modifiers usually occupy the position between two objects.
 Position 1     Position 2     midfieldlast position 
 IchwillIhnen unbedingt meine Arbeit     zeigen.