title: How to sort array of numbers that includes negative values using localecompare?
body: <p>I am trying to sort an array from lowest to highest value.</p>
  
  <p><em>the example below shows it already sorted in this manner</em></p>
  
  <pre><code>var array = ["-394","-275","-156","-37","82","201","320","439","558","677","796"];
  </code></pre>
  
  <p>However when I do this:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var array = ["-394", "-275", "-156", "-37", "82", "201", "320", "439", "558", "677", "796"];
  array.sort(function(a, b) {
    return a.localeCompare(b, undefined, {
      numeric: true
    })
  });
  console.log(array);</code></pre>
  </div>
  </div>
  </p>
  
  <p>This is returned (i'm not sure what sorting has occurred):</p>
  
  <pre><code>["-37", "-156", "-275", "-394", "82", "201", "320", "439", "558", "677", "796"]
  </code></pre>
  
  <p>I've looked at:</p>
  
  <p><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/localeCompare" rel="nofollow noreferrer">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/localeCompare</a></p>
  
  <p>but it doesn't seem to mentioned anything specifically about handling negative numbers.  </p>
  
  <p>What is the correct way to sort an array of numbers that includes negative values?</p>