MCPcopy Index your code
hub / github.com/github/awesome-copilot / sortInstructions

Function sortInstructions

website/src/scripts/pages/instructions-render.ts:21–34  ·  view source on GitHub ↗
(
  items: T[],
  sort: InstructionSortOption
)

Source from the content-addressed store, hash-verified

19export type InstructionSortOption = 'title' | 'lastUpdated';
20
21export function sortInstructions<T extends RenderableInstruction>(
22 items: T[],
23 sort: InstructionSortOption
24): T[] {
25 return [...items].sort((a, b) => {
26 if (sort === 'lastUpdated') {
27 const dateA = a.lastUpdated ? new Date(a.lastUpdated).getTime() : 0;
28 const dateB = b.lastUpdated ? new Date(b.lastUpdated).getTime() : 0;
29 return dateB - dateA;
30 }
31
32 return a.title.localeCompare(b.title);
33 });
34}
35
36export function renderInstructionsHtml(
37 items: RenderableInstruction[]

Callers 1

sortItemsFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected