Skip to content

Commit

Permalink
Sorting fix
Browse files Browse the repository at this point in the history
  • Loading branch information
dlike230 committed Oct 20, 2019
1 parent 8d59478 commit c277624
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
9 changes: 4 additions & 5 deletions frontend/plan/src/components/selector/CourseList.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@ import Course from "./Course";
const courseSort = (courses, sortMode) => {
const sorted = [...courses];
sorted.sort((courseA, courseB) => {
console.log(courseA, courseB);
switch (sortMode) {
case "Quality":
switch (sortMode && sortMode.toLowerCase()) {
case "quality":
return courseB.course_quality - courseA.course_quality;
case "Difficulty":
case "difficulty":
return courseA.difficulty - courseB.difficulty;
default:
return courseA.id.localeCompare(courseB.id);
Expand Down Expand Up @@ -53,5 +52,5 @@ export default function CourseList({ courses, getCourse, sortMode }) {
CourseList.propTypes = {
courses: PropTypes.arrayOf(PropTypes.object).isRequired,
getCourse: PropTypes.func.isRequired,
sortMode: PropTypes.string,
sortMode: PropTypes.string.isRequired,
};
2 changes: 1 addition & 1 deletion frontend/plan/src/components/selector/Selector.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ const mapStateToProps = state => (
{
courses: state.sections.searchResults.filter(course => course.num_sections > 0),
course: state.sections.course,
sortMode: state.sortMode,
sortMode: state.sections.sortMode,
isLoadingCourseInfo: state.sections.courseInfoLoading,
isSearchingCourseInfo: state.sections.searchInfoLoading,
}
Expand Down

0 comments on commit c277624

Please sign in to comment.