5. Given the function $y=f(x)\left(x, y \in \mathbf{N}_{+}\right)$ satisfies:
(1) For any $a, b \in \mathbf{N}_{+}, a \neq b$, it holds that $a f(a)+b f(b)>a f(b)+b f(a)$;
(2) For any $n \in \mathbf{N}_{+}$, it holds that $f(f(n))=3 n$. Then the value of $f(5)+f(12)$ is $(\quad$.
(A) 17
(B) 21
(C) 25
(D) 29
5.D.

For any $n \in \mathbf{N}_{+}$, from (1) we get
$$
\begin{array}{l}
(n+1) f(n+1)+n f(n) \\
>(n+1) f(n)+n f(n+1),
\end{array}
$$

which means $f(n+1)>f(n)$.
Therefore, $f(x)$ is a monotonically increasing function on $\mathbf{N}_{+}$.
For any $n \in \mathbf{N}_{+}$, from (2) we get
$$
f(3 n)=f(f(f(n)))=3 f(n) \text {. }
$$

Clearly, $f(1) \neq 1$. Otherwise, $3=f(f(1))=f(1)$ $=1$, which is a contradiction.
If $f(1) \geqslant 3$, then
$$
3=f(f(1)) \geqslant f(3)>f(2)>f(1) \geqslant 3 \text {, }
$$

which is a contradiction.
Therefore, $f(1)=2$.
Thus, $f(3)=3 f(1)=6$,
$$
f(6)=f(f(3))=3 \times 3=9 \text {. }
$$

From $6=f(3)<f(4)<f(5)<f(6)=9$, we get $f(4)=7, f(5)=8$.
Then $f(7)=f(f(4))=3 \times 4=12$,
$f(12)=f(f(7))=3 \times 7=21$.
Therefore, $f(5)+f(12)=8+21=29$.