• @poopsmith
    link
    English
    181 year ago

    From MDN:

    If compareFn is not supplied, all non-undefined array elements are sorted by converting them to strings and comparing strings in UTF-16 code units order.

    So, if you’re trying to sort numbers, [6, -2, 2, -7].sort((a, b) => a - b)

    • @Solumbran
      link
      English
      41 year ago

      That might be explainable, but doesn’t make it logical or acceptable.