summaryrefslogtreecommitdiffstats
path: root/navigation
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2019-08-01 10:19:19 +0200
committerGitHub <noreply@github.com>2019-08-01 10:19:19 +0200
commit53077b0da54906feee64a03612e5186043e17341 (patch)
treec99b1456485cfc2ed41f3a1b732e44c4acbc3061 /navigation
parenta4f96a9d8c2d2da40796757f7e9a3023157abd2f (diff)
Merge pull request #6149 from bep/sort-caseinsensitive
Implement lexicographically string sorting
Diffstat (limited to 'navigation')
-rw-r--r--navigation/menu.go8
1 files changed, 5 insertions, 3 deletions
diff --git a/navigation/menu.go b/navigation/menu.go
index 47d40a3c7..2cf9722e9 100644
--- a/navigation/menu.go
+++ b/navigation/menu.go
@@ -15,6 +15,7 @@ package navigation
import (
"github.com/gohugoio/hugo/common/types"
+ "github.com/gohugoio/hugo/compare"
"html/template"
"sort"
@@ -159,10 +160,11 @@ func (by menuEntryBy) Sort(menu Menu) {
var defaultMenuEntrySort = func(m1, m2 *MenuEntry) bool {
if m1.Weight == m2.Weight {
- if m1.Name == m2.Name {
+ c := compare.Strings(m1.Name, m2.Name)
+ if c == 0 {
return m1.Identifier < m2.Identifier
}
- return m1.Name < m2.Name
+ return c < 0
}
if m2.Weight == 0 {
@@ -205,7 +207,7 @@ func (m Menu) ByWeight() Menu {
// ByName sorts the menu by the name defined in the menu configuration.
func (m Menu) ByName() Menu {
title := func(m1, m2 *MenuEntry) bool {
- return m1.Name < m2.Name
+ return compare.LessStrings(m1.Name, m2.Name)
}
menuEntryBy(title).Sort(m)