title: Javascript "Sort()" function for sorting numbers defined in Mozilla Documentation
body: <p>For sorting numbers in javascript we trick function sort() given in Javascript and it works perfectly. The trick is given below:</p>
  
  <p><code>[12, 2, 23, 3, 43, 54].sort(function (a, b) { return  a - b ; } )</code> 
  <a href="https://stackoverflow.com/a/46161805/9282474">Source #1</a> and <a href="https://www.w3schools.com/jsref/jsref_sort.asp" rel="nofollow noreferrer">Source#2</a></p>
  
  <p>I didn't understand what exactly this <code>a - b</code> does. I have checked <a href="https://dxr.mozilla.org/seamonkey/source/js/src/jsarray.c" rel="nofollow noreferrer">source code</a> but its hard to understand. I checked following answer from stackoverflow but my doubt haven't cleared yet.
  <a href="https://stackoverflow.com/q/3423394/9282474">Algorithm of JavaScript “sort()” Function</a></p>
  
  <p>Can anyone explain me what exactly happens at <code>a - b</code>?</p>