diff --git a/src/pages/ProjectList.js b/src/pages/ProjectList.js index 0eac2e3..ed343fc 100644 --- a/src/pages/ProjectList.js +++ b/src/pages/ProjectList.js @@ -17,6 +17,21 @@ import Select from 'react-select'; import PageHeader from '../components/PageHeader'; import Button from '../components/Button'; +// Sort function to prioritize projects with "cmd" in the name +function sortProjectsWithCmd(projects) { + return projects.sort((a, b) => { + const aHasCmd = a.name.toLowerCase().includes('cmd'); + const bHasCmd = b.name.toLowerCase().includes('cmd'); + + // If one has "cmd" and the other doesn't, prioritize the one with "cmd" + if (aHasCmd && !bHasCmd) return -1; + if (!aHasCmd && bHasCmd) return 1; + + // If both have "cmd" or neither has "cmd", maintain alphabetical order + return a.name.localeCompare(b.name); + }); +} + function getAuthUserVotes(uid, voteList) { return Object.values(voteList || {}).filter((vote) => vote.creator === uid); } @@ -394,6 +409,10 @@ class ProjectList extends Component { } }); + // Sort winning and other projects with "cmd" projects at the top + winningProjects = sortProjectsWithCmd(winningProjects); + otherProjects = sortProjectsWithCmd(otherProjects); + let awardCategoryOptions = getAwardCategories(awardCategoryList); if (this.state.groupFilter) { @@ -424,6 +443,11 @@ class ProjectList extends Component { else actualProjects.push(p); }); + // Sort each category with "cmd" projects at the top + projectIdeas = sortProjectsWithCmd(projectIdeas); + actualProjects = sortProjectsWithCmd(actualProjects); + myProjects = sortProjectsWithCmd(myProjects); + return (