@@ -467,6 +467,29 @@ def test_to_dict_empty(self):
467
467
}
468
468
assert result == expected
469
469
470
+ @pytest .mark .parametrize ("zarr_format" , [2 , 3 ])
471
+ async def test_to_dict_order (
472
+ self , memory_store : zarr .storage .MemoryStore , zarr_format : ZarrFormat
473
+ ) -> None :
474
+ with zarr .config .set (default_zarr_format = zarr_format ):
475
+ g = await group (store = memory_store )
476
+
477
+ # Create groups in non-lexicographix order
478
+ dtype = "float32"
479
+ await g .create_array (name = "b" , shape = (1 ,), dtype = dtype )
480
+ child = await g .create_group ("c" , attributes = {"key" : "child" })
481
+ await g .create_array (name = "a" , shape = (1 ,), dtype = dtype )
482
+
483
+ await child .create_array ("e" , shape = (1 ,), dtype = dtype )
484
+ await child .create_array ("d" , shape = (1 ,), dtype = dtype )
485
+
486
+ # Consolidate metadata and re-open store
487
+ await zarr .api .asynchronous .consolidate_metadata (memory_store )
488
+ g2 = await zarr .api .asynchronous .open_group (store = memory_store )
489
+
490
+ assert list (g2 .metadata .consolidated_metadata .metadata ) == ["a" , "b" , "c" ]
491
+ assert list (g2 .metadata .consolidated_metadata .flattened_metadata ) == ["a" , "b" , "c" , "c/d" , "c/e" ]
492
+
470
493
@pytest .mark .parametrize ("zarr_format" , [2 , 3 ])
471
494
async def test_open_consolidated_raises_async (self , zarr_format : ZarrFormat ):
472
495
store = zarr .storage .MemoryStore ()
0 commit comments