Adding .Reverse() to PagesGroup

This commit is contained in:
spf13 2014-08-29 23:50:25 -04:00
parent 41b28462e8
commit b15eb889e8

View file

@ -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
}