title: Dispersing numbers in a javascript array
body: <p>I have an array of <code>10+</code> numbers. They represent coordinates on a circle - in degrees, i.e. each number is in between <code>0</code> and <code>359.999999...</code></p>
  
  <p>The problem I am trying to solve is that when I draw my items on the circle (via html5 canvas api), sometimes they are clustered together and that results in items being drawn onto each other.</p>
  
  <p>So I would like to create an algorithm which disperses items evenly around their initial cluster position. Let's say (and I'd like this to be a configurable option) the minimal distance between two items is <code>5</code> degrees. </p>
  
  <p>So  if the initial array is <code>[5, 41, 97, 101, 103, 158, 201, 214, 216, 217, 320]</code> then I would like the algorithm come up with something like [5, 41, <strong>95</strong>, <strong>100</strong>, <strong>105</strong>, 158, 201, <strong>211, 216, 221</strong>, 320]
  (with bolded items being dispersed around their initial "gravity center" regardless whether those are 2 or more items).</p>
  
  <p>Also what would be neccessary is that the algorithm recognizes 0 and 359 being just 1 unit (degree) apart and also spread such items evenly around.</p>
  
  <p><strong>Has anyone ever created such algorithm or have a good idea how it could be achieved?</strong> Even some general thoughts are welcome.
  I'm sure I could achieve that with plenty of trial and error, but I'd like to hear some educated guesses, if you will, first.</p>