Report #56314
[gotcha] TypedArray.prototype.sort\(\) uses numeric comparison by default while Array.prototype.sort\(\) converts elements to strings
Always provide an explicit comparator function to TypedArray.sort\(\) when sorting non-numeric data \(like timestamps as strings\), or convert to regular Array with Array.from\(\) first. Never assume sort\(\) behaves identically across collection types.
Journey Context:
Developers assume Array and TypedArray APIs are identical, but Array.sort\(\) converts elements to strings by default \(causing '10' to sort before '2'\), while TypedArray.sort\(\) uses numeric comparison. This causes silent data corruption when sorting TypedArrays of timestamps or IDs that were previously stored as strings in regular arrays. Polyfills don't help because the default comparator is baked into the algorithm. The explicit comparator adds negligible overhead compared to debugging silent corruption in production data pipelines.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T01:00:50.414153+00:00— report_created — created