Skip to content

Commit

Permalink
Add sorting to taskarchive.
Browse files Browse the repository at this point in the history
  • Loading branch information
mraron committed Apr 9, 2024
1 parent 27e1729 commit dbeeafc
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions internal/web/handlers/taskarchive/taskarchive.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package taskarchive

import (
"net/http"
"sort"

"github.com/mraron/njudge/internal/njudge"
"github.com/mraron/njudge/internal/web/helpers/i18n"
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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" {
Expand All @@ -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" {
Expand Down

0 comments on commit dbeeafc

Please sign in to comment.