title: How sort multidimensional array considering only index[0] of each subarray?
body: <p>How sort multidimensional array considering only index[0] of each subarray ?</p>
  
  <p>I have this array:</p>
  
  <pre><code> var arr= [
   [13538, 6.4,'mese1'],
   [41308, 9.5,'mesi6'],
   [53656, 8.1,'anno1'],
   [271203, 8.3,'anni5']
  ];
  
  var even= arr;
  var magn= arr;
  </code></pre>
  
  <p>and i would to have <code>even</code> and <code>magn</code> in output like this:</p>
  
  <p>Sort desc by index[0]</p>
  
  <pre><code>var even= [
   [271203, 8.3,'anni5'],
   [53656, 8.1,'anno1'],
   [41308, 9.5,'mesi6'],
   [13538, 6.4,'mese1']
  ];
  </code></pre>
  
  <p>Sort desc by index[1]</p>
  
  <pre><code>var magn= [
   [41308, 9.5,'mesi6'],
   [271203, 8.3,'anni5'],
   [53656, 8.1,'anno1'],
   [13538, 6.4,'mese1']
  ];
  </code></pre>
  
  <p>I tried this code but doesn't work correctly:</p>
  
  <pre><code>console.log(even.sort(ordine_decrescente_eventi));
  console.log(magn.sort(ordine_decrescente_magnitudo));
  
  //ordino un array in maniera decrescente
  function ordine_decrescente_eventi(a,b) {
      return b[0] - a[0];
  }   
  
  function ordine_decrescente_magnitudo(a,b) {
      return b[1] - a[1];
  }   
  </code></pre>
  
  <p>This is the jsfiddle: <a href="https://jsfiddle.net/szoe32xb/" rel="nofollow noreferrer">https://jsfiddle.net/szoe32xb/</a></p>
  
  <p>I hope you can help me and sorry for my english!</p>