Skip to content

Commit

Permalink
Added Alphabetical Sorting for Course/Professor Dropdown (#486)
Browse files Browse the repository at this point in the history
  • Loading branch information
vinnyho authored Oct 6, 2024
1 parent d858051 commit 5bd16b7
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions site/src/component/GradeDist/GradeDist.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,9 @@ const GradeDist: FC<GradeDistProps> = (props) => {

gradeDistData.forEach((match) => match.instructors.forEach((prof) => professors.add(prof)));

professors.forEach((professor) => result.push({ value: professor, text: professor }));
Array.from(professors)
.sort((a, b) => a.localeCompare(b))
.forEach((professor) => result.push({ value: professor, text: professor }));

setProfEntries(result);
setCurrentProf(result[0].value);
Expand All @@ -154,7 +156,9 @@ const GradeDist: FC<GradeDistProps> = (props) => {

gradeDistData.forEach((match) => courses.add(match.department + ' ' + match.courseNumber));

courses.forEach((course) => result.push({ value: course, text: course }));
Array.from(courses)
.sort((a, b) => a.localeCompare(b))
.forEach((course) => result.push({ value: course, text: course }));

setCourseEntries(result);
setCurrentCourse(result[0].value);
Expand Down

0 comments on commit 5bd16b7

Please sign in to comment.