sorting a list with respect to the closest number in the list python
<p>I want to sort a list based on how close a number in the list is to a given number.
so for example:</p>

<pre><code> target_list = [1,2,8,20]
 number = 4

then probably sorted list is [2,1,8,20] 
         as 4-2 = 2
            4-1 = 3
            mod|4-8| = 4
            mod|4-20| = 16
</code></pre>

<p>Incase of collision, I dont really care which one comes first but then I am trying to sort the list on the basis of this distance metric.
What is the best (and pythonic) way to do this.</p>

<p>THanks</p>
