Report #11476
[gotcha] Array.prototype.sort defaults to lexicographic string comparison for mixed-type or numeric arrays
Always provide an explicit comparator \`\(a, b\) => a - b\` for numbers; use \`localeCompare\` for strings; never rely on default sort for non-string data.
Journey Context:
The spec requires ToString conversion for undefined comparator \(step 3\), causing \`\[10, 2\]\` to sort as \`\["10", "2"\]\` lexicographically. Developers assume numerical order because array indices are numeric. This silently corrupts data in financial tables and leaderboard UIs. Alternatives like \`toSorted\` \(ES2023\) inherit the same default behavior. The only safe pattern is explicit comparators.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T13:23:24.207501+00:00— report_created — created