1
0
mirror of https://github.com/osmarks/mycorrhiza.git synced 2024-12-12 05:20:26 +00:00

Categories: Sort the list

This commit is contained in:
Timur Ismagilov 2022-07-11 13:54:31 +05:00
parent a4c9edd0ca
commit 81e67b419a
2 changed files with 5 additions and 2 deletions

View File

@ -23,7 +23,7 @@ package categories
import "sync" import "sync"
// listOfCategories returns names of all categories. // listOfCategories returns unsorted names of all categories.
func listOfCategories() (categoryList []string) { func listOfCategories() (categoryList []string) {
mutex.RLock() mutex.RLock()
for cat, _ := range categoryToHyphae { for cat, _ := range categoryToHyphae {

View File

@ -4,6 +4,7 @@ import (
"embed" "embed"
"github.com/bouncepaw/mycorrhiza/viewutil" "github.com/bouncepaw/mycorrhiza/viewutil"
"log" "log"
"sort"
"strings" "strings"
) )
@ -77,10 +78,12 @@ type listData struct {
} }
func categoryList(meta viewutil.Meta) { func categoryList(meta viewutil.Meta) {
cats := listOfCategories()
sort.Strings(cats)
viewutil.ExecutePage(meta, viewListChain, listData{ viewutil.ExecutePage(meta, viewListChain, listData{
BaseData: &viewutil.BaseData{ BaseData: &viewutil.BaseData{
Addr: "/category", Addr: "/category",
}, },
Categories: listOfCategories(), Categories: cats,
}) })
} }