From 81e67b419aff5054fd55e719fd627ec3c58b3012 Mon Sep 17 00:00:00 2001 From: Timur Ismagilov Date: Mon, 11 Jul 2022 13:54:31 +0500 Subject: [PATCH] Categories: Sort the list --- categories/categories.go | 2 +- categories/views.go | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/categories/categories.go b/categories/categories.go index b004e18..3981e04 100644 --- a/categories/categories.go +++ b/categories/categories.go @@ -23,7 +23,7 @@ package categories import "sync" -// listOfCategories returns names of all categories. +// listOfCategories returns unsorted names of all categories. func listOfCategories() (categoryList []string) { mutex.RLock() for cat, _ := range categoryToHyphae { diff --git a/categories/views.go b/categories/views.go index 96b9dad..67c1aac 100644 --- a/categories/views.go +++ b/categories/views.go @@ -4,6 +4,7 @@ import ( "embed" "github.com/bouncepaw/mycorrhiza/viewutil" "log" + "sort" "strings" ) @@ -77,10 +78,12 @@ type listData struct { } func categoryList(meta viewutil.Meta) { + cats := listOfCategories() + sort.Strings(cats) viewutil.ExecutePage(meta, viewListChain, listData{ BaseData: &viewutil.BaseData{ Addr: "/category", }, - Categories: listOfCategories(), + Categories: cats, }) }