Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/gohugoio/hugo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom <tomaviv57@gmail.com>2020-05-02 12:57:34 +0300
committerGitHub <noreply@github.com>2020-05-02 12:57:34 +0300
commit04b1a6d997e72d9abada28db22650d38ccbcbb39 (patch)
treec085814c371c185d398ac64a0e5df781e4c0b3ec /tpl/compare
parentdd31e800075eebd78f921df8b4865c238006e7a7 (diff)
Add support for sort by boolean
Diffstat (limited to 'tpl/compare')
-rw-r--r--tpl/compare/compare.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/tpl/compare/compare.go b/tpl/compare/compare.go
index 50dafae3c..8ce572273 100644
--- a/tpl/compare/compare.go
+++ b/tpl/compare/compare.go
@@ -252,6 +252,11 @@ func (ns *Namespace) compareGet(a interface{}, b interface{}) (float64, float64)
case timeType:
left = float64(toTimeUnix(av))
}
+ case reflect.Bool:
+ left = 0
+ if av.Bool() {
+ left = 1
+ }
}
bv := reflect.ValueOf(b)
@@ -275,6 +280,11 @@ func (ns *Namespace) compareGet(a interface{}, b interface{}) (float64, float64)
case timeType:
right = float64(toTimeUnix(bv))
}
+ case reflect.Bool:
+ right = 0
+ if bv.Bool() {
+ right = 1
+ }
}
if ns.caseInsensitive && leftStr != nil && rightStr != nil {