title: Sort two dimensional list python
body: <p>I have a two dimensional list like this</p>
  
  <pre><code>a = [[42, 206], [45, 40], [45, 205], [46, 41], [46, 205], [47, 40], [47, 202], [48, 40], [48, 202], [49, 38]]
  </code></pre>
  
  <p>Actually these are coordinates in 2D-Euclidean space. I want to sort it like in a way that close points come in a sequence. So, the list looks like the following</p>
  
  <pre><code>sorted_a = [[45,205],[42,206],[46,205],[47,202],[48,202],[45,40],[46,41],[47,40],[48,40],[49,38]]
  </code></pre>
  
  <p>I have also used the method</p>
  
  <pre><code>sorted_a = sorted(a, key=lambda x: (x[0],x[1]))
  </code></pre>
  
  <p>but it is not returning me required results. Your help is appreciated. Thanks</p>