Skip to content

Commit 8758629

Browse files
committed
Sort dictionary keys before returning consolidated metadata
1 parent b877f89 commit 8758629

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/zarr/core/group.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,13 @@ def to_dict(self) -> dict[str, JSON]:
141141
return {
142142
"kind": self.kind,
143143
"must_understand": self.must_understand,
144-
"metadata": {k: v.to_dict() for k, v in self.flattened_metadata.items()},
144+
"metadata": {
145+
k: v.to_dict()
146+
for k, v in sorted(
147+
self.flattened_metadata.items(),
148+
key=lambda item: (len(item[0].split("/")), item[0]),
149+
)
150+
},
145151
}
146152

147153
@classmethod

0 commit comments

Comments
 (0)