diff --git a/module/timetable/repository/search.go b/module/timetable/repository/search.go index db7b695..828b856 100644 --- a/module/timetable/repository/search.go +++ b/module/timetable/repository/search.go @@ -2,6 +2,7 @@ package timetablerepository import ( "context" + "sort" "strings" "sync" "time" @@ -66,6 +67,11 @@ func (r *impl) SearchCourses(ctx context.Context, conds timetableport.SearchCour }) } + // Sort by code + sort.Slice(courses, func(i, j int) bool { + return courses[i].Code.String() < courses[j].Code.String() + }) + // Apply offset courses = courses[lo.Clamp(conds.Offset, 0, len(courses)):]