Skip to content

Commit 9589940

Browse files
committed
sort
1 parent b6dadbe commit 9589940

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

flopy4/mf6/spec.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,22 @@ def array(
106106
Block = dict[str, Attribute]
107107

108108

109+
def _block_sort_key(item) -> int:
110+
k, _ = item
111+
if k == "options":
112+
return 0
113+
elif k == "dimensions":
114+
return 1
115+
elif k == "griddata":
116+
return 2
117+
elif k == "packagedata":
118+
return 3
119+
elif k == "perioddata":
120+
return 4
121+
else:
122+
return 5
123+
124+
109125
def blocks(cls) -> list[list[Attribute]]:
110126
"""Return an ordered list of blocks for a component class."""
111127
return [list(v.values()) for v in blocks_dict(cls).values()]
@@ -125,4 +141,4 @@ def blocks_dict(cls) -> dict[str, Block]:
125141
if block not in blocks:
126142
blocks[block] = {}
127143
blocks[block][k] = v
128-
return blocks
144+
return dict(sorted(blocks.items(), key=_block_sort_key))

0 commit comments

Comments
 (0)