Report #63120
[gotcha] \[10, 2, 1\].sort\(\) returns \[1, 10, 2\] due to string coercion
Always provide comparator: arr.sort\(\(a, b\) => a - b\) for numbers, or new Intl.Collator\(\).compare for locale-aware strings.
Journey Context:
Spec converts elements to strings and compares UTF-16 code units. This is a 1995 legacy from when JS was for simple string sorting. It silently corrupts numeric rankings in data visualizations and financial tables. Using \_.sortBy or explicit comparators is the only safe path.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T12:25:37.183159+00:00— report_created — created