"I will explain everything to your friend."
Translation:Ich werde deinem Freund alles erklären.
If the direct object is a noun (alles), it comes after an indirect object (deinem Freund). If the direct object is a pronoun, it comes before an indirect object.
If two nouns, dative before accusative. If two pronouns, accusative before dative. If one of each, pronoun first irrespective of case. Applying this rule here, alles and deinem Freund are both nouns, so the dative deinem Freund goes first. If the sentence was "I will explain it to your friend" then es would have been a pronoun and come first making the sentence "Ich werde es deinem freund erklären". Hope this helps.
The construction you're talking about is used specifically for body parts e.g.
- Ich putze mir die Zähne
- Ich kämme mir die Haare
- Ich zerbreche mir den Kopf (figurative)
But for just about everything else (can't think of any other noun-categories that use this same construction off the top of my head) you use the possessive pronoun like you would in English.
Doesn't this violate the rule of kurz fuer lang?
I think that should be kurz vor lang, assuming you're referring to the rule of thumb that shorter sentence elements tend to come before longer ones.
Because alles is a pronoun and deinem Freund is a noun so alles should go first, no?
You're right, but here the overriding rule is dative before accusative (or Dativ vor Akkusativ if you want the German), though—as confirmed by wataya—there's nothing wrong with putting "alles" before "deinem Freund" here.
It's one of those things; there are a number of rules for German word order—some stricter than others—that all have an accuracy below 100%, and that sometimes seem to contradict each other (here we have kurz vor lang vs. Dativ vor Akkusativ). They help to give a feeling for where the words should go, but that doesn't mean they should be blindly trusted. I like to think of them as a good starting point and guiding light whilst I develop a gut feeling for the right word order in any given sentence like I have in English (which—even as a native speaker—isn't always there).