MCPcopy
hub / github.com/vinta/awesome-python / sort_entries

Function sort_entries

website/build.py:99–115  ·  view source on GitHub ↗

Sort entries by stars descending, then name ascending. Three tiers: starred entries first, stdlib second, other non-starred last.

(entries: Sequence[TemplateEntry])

Source from the content-addressed store, hash-verified

97
98
99def sort_entries(entries: Sequence[TemplateEntry]) -> list[TemplateEntry]:
100 """Sort entries by stars descending, then name ascending.
101
102 Three tiers: starred entries first, stdlib second, other non-starred last.
103 """
104
105 def sort_key(entry: TemplateEntry) -> tuple[int, int, int, str]:
106 stars = entry["stars"]
107 name = entry["name"].lower()
108 if stars is not None:
109 builtin = 1 if entry.get("source_type") == "Built-in" else 0
110 return (0, -stars, builtin, name)
111 if entry.get("source_type") == "Built-in":
112 return (1, 0, 0, name)
113 return (2, 0, 0, name)
114
115 return sorted(entries, key=sort_key)
116
117
118def build_robots_txt() -> str:

Calls

no outgoing calls