Can you explain your counterexample? Perhaps with with some rates? I don't understand it.
I can't see how it is would be financially beneficial to accelerate the payment of the smaller/cheaper loans over the biggest/costliest one.
I'll concede that paying back your friend sooner than they expect might have a goodwill benefit, but not a monetary one. Even then, I'm not sure how much, over just giving it to them when they asked.