From dbeeafc3e38025aaebdad2d0cac221aece7fd826 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81ron=20Nosz=C3=A1ly?= Date: Tue, 9 Apr 2024 22:49:47 +0200 Subject: [PATCH] Add sorting to taskarchive. --- internal/web/handlers/taskarchive/taskarchive.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/internal/web/handlers/taskarchive/taskarchive.go b/internal/web/handlers/taskarchive/taskarchive.go index ac00aff0..e27803be 100644 --- a/internal/web/handlers/taskarchive/taskarchive.go +++ b/internal/web/handlers/taskarchive/taskarchive.go @@ -2,6 +2,7 @@ package taskarchive import ( "net/http" + "sort" "github.com/mraron/njudge/internal/njudge" "github.com/mraron/njudge/internal/web/helpers/i18n" @@ -45,6 +46,9 @@ func Get(cats njudge.Categories, problemQuery njudge.ProblemQuery, solvedStatusQ if err != nil { return err } + sort.Slice(problemList, func(i, j int) bool { + return problemList[i].ID < problemList[j].ID + }) for _, p := range problemList { elem := TreeNode{ @@ -75,6 +79,9 @@ func Get(cats njudge.Categories, problemQuery njudge.ProblemQuery, solvedStatusQ return err } + sort.Slice(subCategories, func(i, j int) bool { + return subCategories[i].Name < subCategories[j].Name + }) for _, cat := range subCategories { if !cat.Visible { if u == nil || u.Role != "admin" { @@ -100,6 +107,9 @@ func Get(cats njudge.Categories, problemQuery njudge.ProblemQuery, solvedStatusQ return nil } + sort.Slice(lst, func(i, j int) bool { + return lst[i].Name < lst[j].Name + }) for _, start := range lst { if !start.Visible { if u == nil || u.Role != "admin" {