title: Is such a short sorting function correct and universal?
body: <p>According to <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/sort" rel="nofollow noreferrer">Array.prototype.sort() description</a>:</p>
  <blockquote>
  <p>Since version 10 (or EcmaScript 2019), the <a href="https://tc39.es/ecma262/#sec-array.prototype.sort" rel="nofollow noreferrer">specification</a> dictates that <code>Array.prototype.sort</code> is stable.</p>
  </blockquote>
  <p>It won't swap <code>[a,b]</code> if <code>a == b</code>. It also won't swap them if <code>a &lt; b</code>.</p>
  <p>Then a short function like this looks valid and universal:</p>
  <pre><code>arr.sort( (a,b) =&gt; a&gt;b )
  </code></pre>
  <p>And before that a short valid one was:</p>
  <pre><code>arr.sort( (a,b) =&gt; a&gt;b||-1 )
  </code></pre>
  <p>Is that a correct and universal way to sort an array? Or am I missing something, and it won't work in some cases?</p>
  <p>(By &quot;universal&quot; I mean it works for any array type: array of numbers, array of strings...)</p>