For $x \in \mathbb{R}^n$ let us denote $x_{[i]}$ the $i$th largest component of $x$ s.t $$ x_{[1]} \geq x_{[2]} \geq x_{[3]}\ge\cdots $$ The function $$ f(x)= \sum_{i=1}^r x_{[i]} $$ is the sum of $r$ largest element of $x$. Here I want to show that for each $x \in \mathbb{R}^n$ $$ y^Tx \leq f(x) $$ for $y \in \mathbb{R}^n$ which satisfies $$ 0 \leq y_i \leq 1 \hspace{2mm}\forall i=1,2,\ldots,n \\ \sum_{i=1}^n y_i = r $$
So, I tried using Lagrange multipliers but I could not take the derivative of $f(x)$. So how can I show this inequality subject to these constraints?
$[i]$ is a permutation of $(1,2,3,\dots,n)$ so that $x_{[i]}\ge x_{[i+1]}$. Therefore, $$ \begin{align} f(x)-y^Tx &=\sum_{i=1}^rx_{[i]}-\sum_{i=1}^ny_{[i]}x_{[i]}\\ &=\sum_{i=1}^r\left(x_{[i]}-y_{[i]}x_{[i]}\right) +\sum_{i=r+1}^n\left(0-y_{[i]}x_{[i]}\right)\\ &=\sum_{i=1}^rx_{[i]}\left(1-y_{[i]}\right) -\sum_{i=r+1}^nx_{[i]}\left(y_{[i]}\right)\\ &=\sum_{i=1}^r\color{#00A000}{\left(x_{[i]}-x_{[r]}\right)}\color{#0000FF}{\left(1-y_{[i]}\right)} -\sum_{i=r+1}^n\color{#C00000}{\left(x_{[i]}-x_{[r]}\right)}\color{#0000FF}{\left(y_{[i]}\right)}\\[6pt] &\ge0 \end{align} $$ since every term in the left sum is $\color{#00A000}{\ge0}$ and every term in the right sum is $\color{#C00000}{\le0}$.
We can subtract $x_{[r]}$ from each term in both sums since $$ \sum_{i=1}^r\color{#0000FF}{\left(1-y_{[i]}\right)} -\sum_{i=r+1}^n\color{#0000FF}{\left(y_{[i]}\right)} =r-\sum_{i=1}^ny_{[i]}=0 $$