title: sorting multidimensional array numerically and lexicographically javascript
body: <p>I have been breaking my brain for the last 2 days trying to find a solution to the problem but I can't figure it out. </p>
  
  <p>I need to sort an array of arrays first numerically and then lexicographically. While a custom a &lt; b function can solve the first, a normal array.sort() can do the second. But I have no clue how to combine them.</p>
  
  <p>I have an array similar to this one:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var arr = [
      [ '80', '1', '230' ],
      [ '9', '1', '230' ],
      [ 'Ken', '6', '100' ],
      [ 'Dan', '2', '800' ],
      [ 'Tom', '6', '500' ],
      [ 'team10', '2', '222' ],
      [ 'team9', '2', '222' ]
    ];</code></pre>
  </div>
  </div>
  </p>
  
  <p>This array needs to be sorted numerically first according to the numbers in arr[n][1] (largest to smallest). Results with the same arr[n][1] value need to them be ordered numerically according to arr[n][2] (largest to smallest). And finally results with the same value [n][1] and [n][2] need to be ordered lexigographically based on arr[n][0].</p>
  
  <p>The farthest I have gotten so far is this approach:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function sortArr() {
         arr.sort(function(a,b) {
            if (a[1] === b[1]) {
                if (a[2] === b[2]) {
                    return b[0] &lt; a[0];
                }
                return a[2]-b[2];
            }
            return b[1]-a[1]
        });
    }</code></pre>
  </div>
  </div>
  </p>
  
  <p>While the numerical sorting works with this, the lexicographical sorting doesn't. Any help would be appreciated.</p>