mirror of
https://github.com/yusing/godoxy.git
synced 2026-04-24 09:48:49 +02:00
fix(homepage): improve alphabetical sorting by normalizing item names (#181)
- Updated the sorting function to use Title case for item names to ensure consistent alphabetical ordering.
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
|||||||
"github.com/yusing/ds/ordered"
|
"github.com/yusing/ds/ordered"
|
||||||
"github.com/yusing/godoxy/internal/homepage/widgets"
|
"github.com/yusing/godoxy/internal/homepage/widgets"
|
||||||
"github.com/yusing/godoxy/internal/serialization"
|
"github.com/yusing/godoxy/internal/serialization"
|
||||||
|
strutils "github.com/yusing/goutils/strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
type (
|
type (
|
||||||
@@ -146,13 +147,13 @@ func (c *Category) sortByClicks() {
|
|||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
// fallback to alphabetical
|
// fallback to alphabetical
|
||||||
return strings.Compare(a.Name, b.Name)
|
return strings.Compare(strutils.Title(a.Name), strutils.Title(b.Name))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Category) sortByAlphabetical() {
|
func (c *Category) sortByAlphabetical() {
|
||||||
slices.SortStableFunc(c.Items, func(a, b *Item) int {
|
slices.SortStableFunc(c.Items, func(a, b *Item) int {
|
||||||
return strings.Compare(a.Name, b.Name)
|
return strings.Compare(strutils.Title(a.Name), strutils.Title(b.Name))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user