/** Locale-independent Unicode code-point ordering for canonical fleet evidence. */ export function compareCodePoints(left: string, right: string): number { const leftPoints = Array.from(left, (character): number => character.codePointAt(0) ?? 0); const rightPoints = Array.from(right, (character): number => character.codePointAt(0) ?? 0); const sharedLength = Math.min(leftPoints.length, rightPoints.length); for (let index = 0; index < sharedLength; index += 1) { const leftPoint = leftPoints[index]; const rightPoint = rightPoints[index]; if (leftPoint === undefined || rightPoint === undefined) continue; if (leftPoint !== rightPoint) return leftPoint < rightPoint ? -1 : 1; } return leftPoints.length < rightPoints.length ? -1 : leftPoints.length > rightPoints.length ? 1 : 0; }