title: Big Number Sorting in Javascript
body: <p>Let me know the difference between two code snippets for sorting an Array.</p>
  <p><strong>Snippet 1</strong> -</p>
  <pre><code>function bigSorting(unsorted) {
      return unsorted.sort((a, b) =&gt; a - b);
  
  }
  </code></pre>
  <p><strong>Snippet 2</strong> -</p>
  <pre><code>function bigSorting(unsorted) {
      return unsorted.sort((a, b) =&gt; {
          if (a.length == b.length) {
              return a &gt; b ? 1 : -1;
          }
  
          return a.length - b.length;
      });
  
  }
  </code></pre>
  <p>I am having this file - <a href="http://codepad.org/IvxUAFEm" rel="nofollow noreferrer">1000 Items to be in an Array</a>, Snippet 2 will be able to sort the data but Snippet 1 won't.</p>
  <hr />
  <p>FYI -</p>
  <p>Problem Statement -</p>
  <p>Consider an array of numeric strings where each string is a positive number with anywhere from to digits. Sort the array's elements in non-decreasing, or ascending order of their integer values and return the sorted array.</p>
  <p>Example</p>
  <p>Return the array ['1', '3', '150', '200'].</p>
  <p>Function Description</p>
  <p>Complete the bigSorting function in the editor below.</p>
  <p>bigSorting has the following parameter(s):</p>
  <p>string unsorted[n]: an unsorted array of integers as strings
  Returns</p>
  <p>string[n]: the array sorted in numerical order
  Input Format</p>
  <p>The first line contains an integer, , the number of strings in .
  Each of the  subsequent lines contains an integer string, .</p>
  <p>Constraints</p>
  <p>Each string is guaranteed to represent a positive integer.
  There will be no leading zeros.
  The total number of digits across all strings in  is between  and  (inclusive).</p>