summaryrefslogtreecommitdiffstats
path: root/tpl/collections
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2017-04-30 19:33:19 +0200
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2017-05-01 15:13:41 +0200
commita3bf118eaa0796892047bb7456fe89824e423f27 (patch)
treeabe34c808992bc84e4fb6476c670ac246eca52c7 /tpl/collections
parent656155736721547fef45466a28295f6a563cdd1f (diff)
tpl/compare: Make it a package that stands on its own
See #3042
Diffstat (limited to 'tpl/collections')
-rw-r--r--tpl/collections/sort.go8
1 files changed, 5 insertions, 3 deletions
diff --git a/tpl/collections/sort.go b/tpl/collections/sort.go
index 313ba1e83..79ed39913 100644
--- a/tpl/collections/sort.go
+++ b/tpl/collections/sort.go
@@ -23,6 +23,8 @@ import (
"github.com/spf13/hugo/tpl/compare"
)
+var comp = compare.New()
+
// Sort returns a sorted sequence.
func (ns *Namespace) Sort(seq interface{}, args ...interface{}) (interface{}, error) {
if seq == nil {
@@ -129,15 +131,15 @@ func (p pairList) Less(i, j int) bool {
if iv.IsValid() {
if jv.IsValid() {
// can only call Interface() on valid reflect Values
- return compare.Lt(iv.Interface(), jv.Interface())
+ return comp.Lt(iv.Interface(), jv.Interface())
}
// if j is invalid, test i against i's zero value
- return compare.Lt(iv.Interface(), reflect.Zero(iv.Type()))
+ return comp.Lt(iv.Interface(), reflect.Zero(iv.Type()))
}
if jv.IsValid() {
// if i is invalid, test j against j's zero value
- return compare.Lt(reflect.Zero(jv.Type()), jv.Interface())
+ return comp.Lt(reflect.Zero(jv.Type()), jv.Interface())
}
return false