Let's say I have an array arr of doubles:
arr = 120,121,118,119,117,123,120
And a value x
x = 120
I want to get this value
newarr = 120,120,119,121,118,117,123
Which is a new array, the same size of arr, but the values are sorted in relation to the value x, having the closest value first (doesn't matter if it's ascending or descending).
Any idea?