Given a multiset of integers, order them such that the largest absolute prefix sum $$\max_i \left| \sum_{k<i} a_k \right|$$ is smallest. Output any solution if multiple exist.
You can assume input is sorted if it helps.
Test cases:
[1,2,3,4,5] => (Any order)
[-5,-4,1,2,3] => [1,2,-4,3,-5] (or other solutions with value 3)
[-8,4] => [4,-8]
[-9, 4, 9, -6] => [4, -9, 9, -6] (suggested by Jonathan Allan)
Shortest code wins.
[-9, 4, 9, -6] => [4, -9, 9, -6]
\$\endgroup\$