Report #104639
[gotcha] Array.prototype.sort\(\) mutates in place and defaults to string comparison
Always copy before sorting: \`\[...arr\].sort\(\(a, b\) => a - b\)\` for numbers. Never rely on default comparator for numeric arrays.
Journey Context:
The default comparator converts elements to strings and compares UTF-16 code units. So \`\[1, 2, 11, 22\].sort\(\)\` yields \`\[1, 11, 2, 22\]\`. Combining mutation with this unexpected behavior silently corrupts data in reducers or reactive frameworks. The fix avoids both mutation and coercion by using a comparator that returns Number.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-09-20T20:03:12.426680+00:00— report_created — created