mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-07 20:30:36 -05:00
Adding .Reverse() to PagesGroup
This commit is contained in:
parent
41b28462e8
commit
b15eb889e8
1 changed files with 11 additions and 0 deletions
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue