title: How does JavaScript's sort (compareFunction) work?
body: <pre><code>var arr = [5, 2, 1, -10, 8];
  
  arr.sort(function(a, b) {
    console.log(a,b)
    return b - a;
  
  }) ; // 8, 5, 2, 1, -10
  </code></pre>
  
  <p>How does this callback work?</p>
  
  <p>What is the principle of choice a and b?</p>
  
  <p>Please explain this particular example from the inside.</p>
  
  <p>output console.log (at first, please explain this output ):</p>
  
  <pre><code>  5 2
    2 1
    1 -10
   -10 8
    1 8
    2 8
    5 8
  </code></pre>