Skip to content

Commit 86cf67f

Browse files
authored
[libc][newhdrgen] add_function by alphabetical order (#102527)
- add_function now adds the function by alphabetical order
1 parent ba97697 commit 86cf67f

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

libc/newhdrgen/yaml_to_classes.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,15 @@ def add_function_to_yaml(yaml_file, function_details):
190190
if new_function.attributes:
191191
function_dict["attributes"] = new_function.attributes
192192

193-
yaml_data["functions"].append(function_dict)
193+
insert_index = 0
194+
for i, func in enumerate(yaml_data["functions"]):
195+
if func["name"] > new_function.name:
196+
insert_index = i
197+
break
198+
else:
199+
insert_index = len(yaml_data["functions"])
200+
201+
yaml_data["functions"].insert(insert_index, function_dict)
194202

195203
class IndentYamlListDumper(yaml.Dumper):
196204
def increase_indent(self, flow=False, indentless=False):

0 commit comments

Comments
 (0)