How to sort an array that has 3 values per row? : <p>This is my array that I have to sort from highest average grade to lowest.</p>

<pre><code>let students= [
         {name:"Petar", year:1, average:4.35},
         {name:"Ivana", year:1, average:3.88},
         {name:"Marko", year:2, average:2.27},
         {name:"Davor", year:2, average:4.15},
         {name:"Petra", year:3, average:3.99},
         {name:"Ivan", year:3, average:4.33},
         {name:"Goran", year:3, average:3.74}
     ];


students.sort(function(a,b){
         return a[1] - b[1];
     });
</code></pre>
