mirror of
https://github.com/vinta/awesome-python.git
synced 2026-03-23 13:56:43 +08:00
fix(website): sort starred stdlib entries after starred non-stdlib entries
Within the same star count, built-in (stdlib) entries were interleaved with third-party entries. Add a builtin tier to the sort key so stdlib entries always rank below non-stdlib entries at equal star counts. Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -80,14 +80,15 @@ def sort_entries(entries: list[dict]) -> list[dict]:
|
||||
Three tiers: starred entries first, stdlib second, other non-starred last.
|
||||
"""
|
||||
|
||||
def sort_key(entry: dict) -> tuple[int, int, str]:
|
||||
def sort_key(entry: dict) -> tuple[int, int, int, str]:
|
||||
stars = entry["stars"]
|
||||
name = entry["name"].lower()
|
||||
if stars is not None:
|
||||
return (0, -stars, name)
|
||||
builtin = 1 if entry.get("source_type") == "Built-in" else 0
|
||||
return (0, -stars, builtin, name)
|
||||
if entry.get("source_type") == "Built-in":
|
||||
return (1, 0, name)
|
||||
return (2, 0, name)
|
||||
return (1, 0, 0, name)
|
||||
return (2, 0, 0, name)
|
||||
|
||||
return sorted(entries, key=sort_key)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user