MCPcopy
hub / github.com/github/awesome-copilot / sortIssues

Function sortIssues

extensions/backlog-swipe-triage/extension.mjs:169–194  ·  view source on GitHub ↗
(issues, sortBy)

Source from the content-addressed store, hash-verified

167}
168
169function sortIssues(issues, sortBy) {
170 const sorted = [...issues];
171 if (sortBy === "random") {
172 for (let i = sorted.length - 1; i > 0; i -= 1) {
173 const j = Math.floor(Math.random() * (i + 1));
174 [sorted[i], sorted[j]] = [sorted[j], sorted[i]];
175 }
176 return sorted;
177 }
178 sorted.sort((left, right) => {
179 if (sortBy === "created-asc") {
180 return parseDateToMs(left.createdAt) - parseDateToMs(right.createdAt);
181 }
182 if (sortBy === "created-desc") {
183 return parseDateToMs(right.createdAt) - parseDateToMs(left.createdAt);
184 }
185 if (sortBy === "updated-asc") {
186 return parseDateToMs(left.updatedAt) - parseDateToMs(right.updatedAt);
187 }
188 if (sortBy === "title-asc") {
189 return normalizeText(left.title).localeCompare(normalizeText(right.title));
190 }
191 return parseDateToMs(right.updatedAt) - parseDateToMs(left.updatedAt);
192 });
193 return sorted;
194}
195
196function normalizeItem(raw, index) {
197 const idFromInput = normalizeText(raw?.id);

Callers 1

syncBoardFromRepoFunction · 0.85

Calls 2

parseDateToMsFunction · 0.85
normalizeTextFunction · 0.70

Tested by

no test coverage detected