Skip to content

Commit

Permalink
ensure lists are always sorted in some way so output it deterministic #…
Browse files Browse the repository at this point in the history
  • Loading branch information
proycon committed Sep 18, 2023
1 parent cbe59af commit dec8ec3
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion codemeta/serializers/jsonld.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def alt_sort_key(data) -> str:
return data["identifier"]
elif isinstance(data, str):
return data
return "~" # just a high alphanumeric character so it ends up after normal (ascii) stuff
return "~" + repr(data) # just sort by raw representiation so we ensure output is always deterministic, we prefix it with a high alphanumeric character so it ends up after normal (ascii) stuff we do know how to sort


def sort_by_position(data: Union[list, dict, tuple, str]) -> Union[list, dict, str]:
Expand Down

0 comments on commit dec8ec3

Please sign in to comment.