mirror of
https://github.com/gohugoio/hugo.git
synced 2025-03-19 16:43:03 +00: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"
|
"errors"
|
||||||
"reflect"
|
"reflect"
|
||||||
"sort"
|
"sort"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
type PageGroup struct {
|
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) {
|
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 {
|
if len(p) < 1 {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue