5. On the graph of the function $y=-\frac{a^{2}+1}{x}(a$ is a constant $)$, there are points $A\left(-1, y_{1}\right) 、 B\left(\frac{1}{4}, y_{2}\right) 、 C\left(\frac{1}{2}, y_{3}\right)$. The size relationship of the function values $y_{1} 、 y_{2} 、 y_{3}$ is ( ).
(A) $y_{1}<y_{2}<y_{3}$
(B) $y_{3}<y_{2}<y_{1}$
(C) $y_{3}<y_{1}<y_{2}$
(D) $y_{2}<y_{1}<y_{3}$
5. C.

Since $-\left(a^{2}+1\right)<0$, in each quadrant, $y$ increases as $x$ increases. Therefore, $y_{1}<y_{2}$. Also, $\left(-1, y_{1}\right)$ is in the second quadrant, while $\left(\frac{1}{2}, y_{3}\right)$ is in the fourth quadrant, so $y_{3}<y_{1}$.