From 81fdb0b959c8c826712564449f60d5938a870070 Mon Sep 17 00:00:00 2001 From: David Montero Date: Sun, 31 May 2026 08:26:16 +0200 Subject: [PATCH] feat(examples): order gallery by board (Arduino Uno first), then title MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sort filteredExamples by the board's position in BOARD_TABS — which puts Arduino Uno first — and alphabetically by title within each board. Applies to the 'All' view and to each board tab. Co-Authored-By: Claude Opus 4.7 --- frontend/src/components/examples/ExamplesGallery.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/frontend/src/components/examples/ExamplesGallery.tsx b/frontend/src/components/examples/ExamplesGallery.tsx index c5f36d25..3cbe46ee 100644 --- a/frontend/src/components/examples/ExamplesGallery.tsx +++ b/frontend/src/components/examples/ExamplesGallery.tsx @@ -102,7 +102,15 @@ export const ExamplesGallery: React.FC = ({ onLoadExample if (searchTokens.length === 0) return true; const hay = exampleHaystack(example); return searchTokens.every((tok) => hay.includes(tok)); - }); + }) + .sort((a, b) => { + // Order by board following the BOARD_TABS order (so Arduino Uno comes + // first), then alphabetically by title within each board. + const ra = BOARD_TABS.findIndex((t) => t.id === getBoardFilter(a)); + const rb = BOARD_TABS.findIndex((t) => t.id === getBoardFilter(b)); + if (ra !== rb) return (ra < 0 ? 999 : ra) - (rb < 0 ? 999 : rb); + return (a.title ?? '').localeCompare(b.title ?? ''); + }); // Count per board for tab badges const boardCounts: Record = { all: exampleProjects.length };