title: Google Script sort 2D Array by any column
body: <p>I had a asked an earlier question about retrieving records from a database, here: <a href="https://stackoverflow.com/questions/25872861/retrieving-records-from-a-google-sheet-with-google-script">Retrieving Records from a Google Sheet with Google Script</a></p>
  
  <p>I'm fairly comfortable with manipulating arrays and creating my own sorting algorithms, but I want to use the existing <code>Array.sort()</code> method to organize the data because of its speed. I'm finding that I can easily use this to sort a 2D array by the first column of data, but I can't find the syntax to sort on a different column of data, other than the first. </p>
  
  <p>The closest that I've found is this: <a href="https://stackoverflow.com/questions/15859024/google-apps-script-aditional-sorting-rules">Google Apps Script Additional Sorting Rules</a>. However, these inputs haven't worked for me. Here is what I get for the following code, for my array, tableData:</p>
  
  <pre><code>tableData.sort([{ column: 1}]);
  </code></pre>
  
  <p>=>TypeError: (class)@4dde8e64 is not a function, it is object. (line 49, file "sortTablebyCol")</p>
  
  <pre><code>tableData.sort([{column: 1, ascending: true}]);
  </code></pre>
  
  <p>=> TypeError: (class)@4d89c26e is not a function, it is object. (line 50, file "sortTablebyCol")</p>
  
  <p>What is the proper syntax for choosing which column of data to sort on?</p>