So far I only meet optimization problems solved by searching for an optimal point in $\mathbb{R}^n$. But today I met with an optimization problem that asks me to search within a set of functions. My previous knowledge on optimization such as Lagrangian multiplier method and KKT suddenly loses its power. I have no idea about how to handle it.
The question is as follows: Given a pmf, i.e., a finite sequence of positive values $q_1,q_2,\ldots,q_n$ satisfying $\sum\limits_{i=1}^n q_i=1$, try to find
$\mathrm{argmin}\sum\limits_{i=1}^n iq_{P(i)}$ within all permutation $P$ of the given pmf.
I guess the answer is the permutation that sorts the pmf in a nonincreasing order. But how to obtain it? Which brach of mathematics aims at this kind of optimization problems with regard to functions? Thank you for your answer.