Skip to content

Commit 2b2caf7

Browse files
fix sort
1 parent b6dd2d3 commit 2b2caf7

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

linodecli/documentation/template_data.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -185,14 +185,14 @@ def from_iter(
185185
cls,
186186
data: Iterable[T],
187187
get_parent: Callable[[T], Optional[str]],
188-
get_name: Callable[[T], str],
188+
sort_key: Callable[[T], Any],
189189
) -> List[Self]:
190190
"""
191191
Builds a list of FieldSection created from the given data using the given functions.
192192
193193
:param data: The data to partition.
194194
:param get_parent: A function returning the parent of this entry.
195-
:param get_name: A function returning the name of this entry.
195+
:param sort_key: A function passed into the `key` argument of the sort function.
196196
197197
:returns: The built list of sections.
198198
"""
@@ -206,7 +206,7 @@ def from_iter(
206206

207207
return sorted(
208208
[
209-
FieldSection(name=key, entries=sorted(section, key=get_name))
209+
FieldSection(name=key, entries=sorted(section, key=sort_key))
210210
for key, section in sections.items()
211211
],
212212
key=lambda section: section.name,
@@ -301,7 +301,7 @@ def from_openapi(cls, operation: OpenAPIOperation) -> Self:
301301
if isinstance(arg, OpenAPIRequestArg)
302302
),
303303
get_parent=lambda arg: arg.parent if arg.is_child else None,
304-
get_name=lambda arg: arg.path,
304+
sort_key=lambda arg: (not arg.required, arg.path),
305305
)
306306

307307
result.argument_sections_names = {
@@ -319,7 +319,7 @@ def from_openapi(cls, operation: OpenAPIOperation) -> Self:
319319
if "." in attr.name
320320
else None
321321
),
322-
get_name=lambda arg: arg.name,
322+
sort_key=lambda attr: attr.name,
323323
)
324324

325325
result.attribute_sections_names = {

0 commit comments

Comments
 (0)