Showing $trace\left(\sum_{i=1}^j u_i u_i^T D\right) \leq \sum_{i=1}^j \lambda_i$, where $u_i$ orthonormal & $D$ a diag. matrix w/ $\lambda_i$ entries? Suppose $\{u_i:1 \leq i \leq j\}$ are a set of orthonormal vectors,  and $D$ is a diagonal marix such that $D = diag(\lambda_1, \ldots, \lambda_p)$, arranged so that $\lambda_1 \geq \lambda_2 \geq \cdots \geq \lambda_p >0$. Then, I would like to show that:
$$
trace\left(\sum_{i=1}^j u_i u_i^T D\right) \leq \sum_{i=1}^j \lambda_i
$$
My approach is to do the following:
\begin{align*}
trace\left(\sum_{i=1}^j u_i u_i^T D\right) &= \sum_{i=1}^j \sum_{l=1}^p u_{il}^2 \lambda_l \\
&= \sum_{l=1}^p u_{1l}^2 \lambda_l + \sum_{l=1}^p u_{2l}^2 \lambda_l + \ldots + \sum_{l=1}^p u_{jl}^2 \lambda_l \\
& \leq \lambda_1 + \ldots + \lambda_j
\end{align*}
However, I cannot figure out how the last step follows. I understand we have that:
$$
\sum_{l=1}^p u_{1l}^2 = \sum_{l=1}^p u_{2l}^2 = \ldots = \sum_{l=1}^p u_{jl}^2 = 1
$$
But I don't see how this allows us to get the last inequality. In particular, it seems that we are just concentrating all the weighting to $u_{11}^2 = u_{22}^2 = \ldots = u_{jj}^2 = 1$ for each term.
Finally, if the last inequality holds, would it hold for any arbitrary reordering of the indices?
 A: Let $x_i = u_{1,i}^2 + u_{2,i}^2 + \cdots + u_{j, i}^2$ for $1 \leq i \leq p$. Exactly we want to find the maximum value of
$$
x_1\lambda_1 + x_2\lambda_2 + \cdots + x_p\lambda_p \tag{$\bigstar$}
$$
There are at least two constraints for $x_i$s, namely,
$$
x_1 + x_2 + \cdots + x_p = j \tag{$\spadesuit$}
$$
and
$$
0 \leq x_i \leq 1 \text{ for } 1 \leq i \leq p \tag{$\clubsuit$}
$$
With only constraints $(\spadesuit)$ and $(\clubsuit)$, along with the fact that $\lambda_1 \geq \lambda_2 \geq \cdots \geq \lambda_p > 0$, $(\bigstar)$ attains its maximum value when $x_1 = x_2 = \cdots = x_j = 1$ and $x_{j+1} = x_{j+2} = \cdots = x_p = 0$. That is, the maximum value of $(\bigstar)$ under $(\spadesuit)$ and $(\clubsuit)$ is $\lambda_1 + \lambda_2 + \cdots + \lambda_j$. Because we obtain this value under weaker constraints than that of the original problem, the value $\lambda_1 + \lambda_2 + \cdots + \lambda_j$ is also an upper bound for the original problem.
A: Here's a quick approach: let $U$ be the matrix whose columns are $u_1,\dots,u_j$. Notably, we have
$$
\sum_{i=1}^j u_iu_i^TD = (UU^TD)
$$
And we note that $UU^T$ is a $p \times p$ orthogonal projection matrix, which is to say that it is orthogonally similar to
$$
\pmatrix{I_j & 0\\0& 0}
$$
Both $UU^T$ and $D$ are positive definite, so their eigenvalues are also their singular values.  In particular, $\sigma_i(D) = \lambda_i(D)$, $\sigma_i(UU^T) = 1$ for $i \leq j$ and $\sigma_i(UU^T) = 0$ for $i > j$. Applying the Von Neumann matrix inequality, we have
$$
trace\left(\sum_{i=1}^j u_i u_i^T D\right) = 
trace([UU^T]D) \leq \sum_{i=1}^p \sigma_i(UU^T)\sigma_i(D) = \sum_{i=1}^j \lambda_i
$$
