title: Sort an array of items (with X/Y properties) so they are ordered left to right, top to bottom
body: <p>Each item in the array in on the stage, each with an x/y position. The item in the top left most position should be items[0]. X should be the primary. </p>
  
  <p><img src="https://i.stack.imgur.com/pgKzU.png" alt="enter image description here"></p>
  
  <p>Originally I was thinking along the lines of:  </p>
  
  <pre><code>var items = [m1, m2, m3, m4, m5, m6];
  
  items.sort(sortMe);    
  
  function sortMe(a, b)
  {
      return (b.position[0] - a.position[0]) &amp;&amp; (b.position[1] - a.position[1]);
  }
  </code></pre>
  
  <p>But this does not yield the correct results. </p>