MCPcopy Create free account
hub / github.com/github/awesome-copilot / sortTools

Function sortTools

website/src/scripts/pages/tools-render.ts:32–44  ·  view source on GitHub ↗
(
  tools: T[],
  sort: ToolSortOption
)

Source from the content-addressed store, hash-verified

30export type ToolSortOption = "featured" | "title";
31
32export function sortTools<T extends RenderableTool>(
33 tools: T[],
34 sort: ToolSortOption
35): T[] {
36 return [...tools].sort((a, b) => {
37 if (sort === "featured") {
38 if (a.featured && !b.featured) return -1;
39 if (!a.featured && b.featured) return 1;
40 }
41
42 return a.title.localeCompare(b.title);
43 });
44}
45
46function formatMultilineText(text: string): string {
47 return escapeHtml(text).replace(/\r?\n/g, "<br>");

Callers 1

sortItemsFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected