Original problem: $$ \begin{aligned} \mathbf{w}^*&= \underset{\mathbf{w}}{\mathrm{Argmax}} ~ \text{Sort} \left[ R_1\mathbf{w} \right]^T \mathbf{p} - c||\mathbf{w}-\mathbf{w}_0||_1 \\s.t.~\\ ||\mathbf{w}||_\infty&\leq 1 \end{aligned} $$
Second problem $(R_2=-R_1)$: $$ \begin{aligned} \mathbf{w}^*&= \underset{\mathbf{w}}{\mathrm{Argmin}} ~ \text{Sort} \left[ R_2\mathbf{w} \right]^T \mathbf{p} + c||\mathbf{w}-\mathbf{w}_0||_1 \\s.t.~\\ ||\mathbf{w}||_\infty&\leq 1 \end{aligned} $$
Bilevel optimization: $$ \begin{aligned} \mathbf{w}^* &= \underset{\mathbf{w}}{\mathrm{Argmin}} ~ \left[ M (R\mathbf{w}) \right]^T \mathbf{p} + c||\mathbf{w}-\mathbf{w}_0||_1 \\ M &\in \underset{M}{\mathrm{Argmin}}~\mathbf{v}^T M(R\mathbf{w}) \\ \mathbf{v}&= (1,2,3,\ldots,nrow(M))^T \\s.t.~\\ ||\mathbf{w}||_\infty&\leq 1 \\\sum_i M_{i,j} &= 1 \\\sum_j M_{i,j} &= 1 \\M_{i,j} &\in \{0,1\} \end{aligned} $$
$R$ is a tall random matrix of shape around $100000\times1000$.
$\mathbf{p}$ is a univariate probability mass function of an arbitrary distribution within $(0,1)$. $\mathbf{p}$ matches with each row of the sorted $R\mathbf{w}$. All elements in $\mathbf{p}$ are positive and ideally, they have a sum equal to $1$. $\mathbf{p}$ can be sorted as well.
Here I rewrite the 'Sort' part using permutation matrix $M$. It is okay to assume the 'Sort' as increasing or decreasing ($\text{Sort} \left[R\mathbf{w} \right]^T \mathbf{p}$ as largest element with largest weight or largest element with smallest weight). The 'Sort' part can be relaxed, a weak approximation is acceptable.
Please let me know if there's an algo or solver for it, or if you have any ideas. Thx a lot!