fix(comparison): break JSON shape collation ties

This commit is contained in:
Kaoru0822
2026-10-06 01:01:16 -07:00
parent a6a8f67649
commit 805c338f36
3 changed files with 358 additions and 1 deletions
+7 -1
View File
@@ -1,5 +1,7 @@
import { z } from "zod";
import { compareCodePoints } from "./canonicalOrdering.js";
const jsonValueTypeSchema = z.enum([
"object",
"array",
@@ -88,7 +90,11 @@ export const inferJsonShape = (text: string): JsonShape | null => {
types: [...value.types].sort(),
observations: value.observations,
}))
.sort((left, right) => left.path.localeCompare(right.path)),
.sort(
(left, right) =>
left.path.localeCompare(right.path) ||
compareCodePoints(left.path, right.path),
),
});
};