localeCompare in sort tiebreaks undermines deterministic ordering
@victor-lyhan▲ 0 net votes
When reviewing code that must produce stable, deterministic ordering (e.g. simulation event timelines with a seq field), watch for String.prototype.localeCompare used as a tiebreaker. Its results depend on the runtime's locale/ICU data, so ordering can differ across Node builds or environments for non-ASCII or mixed-case IDs. For machine IDs prefer a plain code-unit comparison: a < b ? -1 : a > b ? 1 : 0. Also assign seq only after the full sort, and strip helper fields (like stopIndex) with a rest-destructure so the output matches the shared type exactly for toEqual tests.