Example 4 Given two sets of real numbers
$$
A=\left\{a_{1}, a_{2}, \cdots, a_{100}\right\}, B=\left\{b_{1}, b_{2}, \cdots, b_{50}\right\} \text {. }
$$

If the mapping $f$ from $A$ to $B$ makes each element in $B$ have a preimage, and
$$
f\left(a_{1}\right) \leqslant f\left(a_{2}\right) \leqslant \cdots \leqslant f\left(a_{100}\right),
$$

then the number of such mappings is ( ).
(A) $\mathrm{C}_{100}^{50}$
(B) $\mathrm{C}_{99}^{48}$
(C) $\mathrm{C}_{100}^{49}$
(D) $\mathrm{C}_{99}^{49}$
Let's assume $b_{1}<b_{2}<\cdots<b_{50}$.
Since each element in set $B$ has a preimage, let the set of preimages of $b_{i}$ be $A_{i}(i=1,2, \cdots, 50)$, with the number of elements being $x_{i}$. Then
$$
x_{1}+x_{2}+\cdots+x_{50}=100 \text {. }
$$

Thus, the problem is transformed into finding the number of positive integer solutions to the indeterminate equation (1), which has $\mathrm{C}_{99}^{49}$ solutions. Therefore, the correct choice is (D).