Given two arrays $\text{A}$ and $\text{B}$ with $\text{M, N}$ elements respectively, minimize :$$\left|\sum_{i=1}^{\text{M}} a_i b_{j_i}\right|$$ where $b_j \in B$.
This cannot be boiled down by a direct application of Rearrangement inequality. The absolute value seems to make it difficult.
I'd appreciate a hint for this. If it is difficult to express mathematically (in terms of a closed form or whatever), an algorithm to work this out would also suffice.
You can solve this via integer linear programming as follows. Let binary decision variable $x_{i,j}$ indicate whether $a_i$ is matched to $b_j$. Then the problem is to minimize $z$ subject to linear constraints: \begin{align} z &\ge \sum_{i,j} a_i b_j x_{i,j}\\ z &\ge -\sum_{i,j} a_i b_j x_{i,j}\\ \sum_j x_{i,j} &= 1 &&\text{for all $i$} \end{align} If each $b_j$ must appear at most once, then you also need to impose $$\sum_i x_{i,j} \le 1 \quad \text{for all $j$}.$$