Skip to content

Commit

Permalink
Use human sorting for job names
Browse files Browse the repository at this point in the history
  • Loading branch information
ssbarnea committed Aug 12, 2024
1 parent 0b6dba2 commit 6fe3c66
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion entrypoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@
IMPLICIT_SKIP_EXPLODE = "0"


def sort_human(l: list[str]) -> list[str]:
"""Sort a list using human logic, so 'py39' comes before 'py311'."""
def convert(text: str) -> str | float:
return float(text) if text.isdigit() else text
def alphanum(key):
return [convert(c) for c in re.split("([-+]?[0-9]*\\.?[0-9]*)", key)]
l.sort(key=alphanum)
return l

def add_job(result: dict[str, dict[str, str]], name: str, data: dict[str, str]) -> None:
"""Adds a new job to the list of generated jobs."""
if name in result:
Expand Down Expand Up @@ -111,7 +120,7 @@ def main() -> None: # noqa: C901,PLR0912
)

core.info(f"Generated {len(result)} matrix entries.")
names = sorted(result.keys())
names = sort_human(list(result.keys()))
core.info(f"Job names: {', '.join(names)}")
matrix_include = []
matrix_include = [
Expand Down

0 comments on commit 6fe3c66

Please sign in to comment.