From: spf13 Date: Sat, 30 Aug 2014 03:50:25 +0000 (-0400) Subject: Adding .Reverse() to PagesGroup X-Git-Tag: v0.12~13 X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=b15eb889;p=brevno-suite%2Fhugo Adding .Reverse() to PagesGroup --- diff --git a/hugolib/pageGroup.go b/hugolib/pageGroup.go index 77380a6e..5b4b9a5e 100644 --- a/hugolib/pageGroup.go +++ b/hugolib/pageGroup.go @@ -17,6 +17,7 @@ import ( "errors" "reflect" "sort" + "strings" ) type PageGroup struct { @@ -62,6 +63,16 @@ func sortKeys(v []reflect.Value, order string) []reflect.Value { } func (p Pages) GroupBy(key, order string) ([]PageGroup, error) { +type PagesGroup []PageGroup + +func (p PagesGroup) Reverse() PagesGroup { + for i, j := 0, len(p)-1; i < j; i, j = i+1, j-1 { + p[i], p[j] = p[j], p[i] + } + + return p +} + if len(p) < 1 { return nil, nil }