title: Sort 2d array by first element in JavaScript
body: <p>I have a 2d array like so:</p>
  <pre><code>myArray = [ [20,6], [12,6], [17,6], [2,6], [11,5], [18,5], [7,4], [4,4] ];
  </code></pre>
  <p>I wish to sort it by first index values - [2,6] should come before [12,6], [16,6]... [4,4] before [7,4] in that order... to obtain:</p>
  <pre><code>sortedArray = [ [2,6], [12,6], [17,6], [20,6], [11,5], [18,5], [4,4], [7,4] ];
  </code></pre>