title: javascript method sort: end of task
body: <p>I'm sorting a big array in JavaScript via the method array.sort(), </p>
  
  <p>While calling sort() I'd like to display a loader gif, in order to show that the script is running.</p>
  
  <p>then I'd like to hide this loader and throw a function: when the task is finished</p>
  
  <p>How can we know whent the new array is available with sort() method ? </p>
  
  <pre><code>// This will sort by Year
  function sortByYear(a, b){
  
      var aYear = parseFloat(a.year)
      var bYear = parseFloat(b.year)
  
      if (aYear &lt; bYear) {
        return 1;
      } else if (aYear &gt; bYear) {
        return -1;
      } else {
        return 0;
      }
  
  }
  </code></pre>