• Quasari@programming.dev
    link
    fedilink
    arrow-up
    21
    ·
    edit-2
    1 year ago

    Array.prototype.sort if no callback is passed to it will coerce non-undefined elements to strings when sorting. It does do that.

    To sort numbers passing a function like (a, b) => a - b is good enough.