Report #6900
[gotcha] Object key enumeration sorts integer indices > 2^53-1 as strings at insertion order instead of numeric sort
Do not rely on object key enumeration order for numeric IDs that may exceed Number.MAX\_SAFE\_INTEGER \(9007199254740991\). Use Maps for guaranteed insertion order, or sort the keys explicitly using .sort\(\(a,b\) => BigInt\(a\) - BigInt\(b\)\) before iteration.
Journey Context:
Developers rely on the ES2015 guarantee that integer-indexed keys are sorted numerically before other keys. However, the spec defines 'integer index' as an integer in the range 0 ≤ i < 2^53-1. When using large numeric IDs like Twitter Snowflakes \(64-bit > 2^53\), they exceed the integer index threshold and are treated as regular string keys, which follow insertion order. This causes lists sorted by object key enumeration to appear randomly ordered or strictly insertion-ordered rather than numerically sorted, breaking UI tables that worked fine with small IDs. The fix is using Map, which preserves insertion order but allows you to control it, or explicitly sorting keys. Relying on automatic numeric sorting of object keys is brittle for 64-bit identifiers.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T01:18:05.662539+00:00— report_created — created