Draft: assume you're given a list of numbers, e.g. [1, 2, 3, 4]
order the list such that sum of the distance from a given number to all other numbers is the smallest, preserving the original order when the sums are the same
for example, in the above list, the distance from 1 to 2 is 1, distance from 1 to 3 is 2, and dist from 1 t o4 is 3 - the sum of that is 6
likewise for 2, you'd get 4
and for 3, you'd get 4
and for 4, you'd get 6