What's the best way of sorting a python list in an unordered fashion according to the median of value positions in the list?
Suppose:
a = [1, 3 ,6, 7, 10, 12, 17]
I'm looking for this:
a = [1, 17, 7, 3, 12, 6, 10]
Meaning, the list now looks like [start, end, mid, first_half_mid, second_half_mid, ...]
edit: To clarify further, I'm looking for a way to keep bisecting the list until it covers the whole range!
edit2: Another example to illustrate the problem
input:
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
desired output:
[1, 10, 6, 3, 9, 2, 5, 8, 4, 7]