//
// This may safely be executed in parallel.
func (p Pages) ByWeight() Pages {
- key := "pageSort.ByWeight"
+ const key = "pageSort.ByWeight"
pages, _ := spc.get(key, pageBy(defaultPageSort).Sort, p)
return pages
}
// This may safely be executed in parallel.
func (p Pages) ByTitle() Pages {
- key := "pageSort.ByTitle"
+ const key = "pageSort.ByTitle"
title := func(p1, p2 *Page) bool {
return p1.title < p2.title
// This may safely be executed in parallel.
func (p Pages) ByLinkTitle() Pages {
- key := "pageSort.ByLinkTitle"
+ const key = "pageSort.ByLinkTitle"
linkTitle := func(p1, p2 *Page) bool {
return p1.linkTitle < p2.linkTitle
// This may safely be executed in parallel.
func (p Pages) ByDate() Pages {
- key := "pageSort.ByDate"
+ const key = "pageSort.ByDate"
date := func(p1, p2 *Page) bool {
return p1.Date.Unix() < p2.Date.Unix()
// This may safely be executed in parallel.
func (p Pages) ByPublishDate() Pages {
- key := "pageSort.ByPublishDate"
+ const key = "pageSort.ByPublishDate"
pubDate := func(p1, p2 *Page) bool {
return p1.PublishDate.Unix() < p2.PublishDate.Unix()
// This may safely be executed in parallel.
func (p Pages) ByExpiryDate() Pages {
- key := "pageSort.ByExpiryDate"
+ const key = "pageSort.ByExpiryDate"
expDate := func(p1, p2 *Page) bool {
return p1.ExpiryDate.Unix() < p2.ExpiryDate.Unix()
// This may safely be executed in parallel.
func (p Pages) ByLastmod() Pages {
- key := "pageSort.ByLastmod"
+ const key = "pageSort.ByLastmod"
date := func(p1, p2 *Page) bool {
return p1.Lastmod.Unix() < p2.Lastmod.Unix()
// This may safely be executed in parallel.
func (p Pages) ByLength() Pages {
- key := "pageSort.ByLength"
+ const key = "pageSort.ByLength"
length := func(p1, p2 *Page) bool {
return len(p1.content()) < len(p2.content())
// This may safely be executed in parallel.
func (p Pages) ByLanguage() Pages {
- key := "pageSort.ByLanguage"
+ const key = "pageSort.ByLanguage"
pages, _ := spc.get(key, pageBy(languagePageSort).Sort, p)
//
// This may safely be executed in parallel.
func (p Pages) Reverse() Pages {
- key := "pageSort.Reverse"
+ const key = "pageSort.Reverse"
reverseFunc := func(pages Pages) {
for i, j := 0, len(pages)-1; i < j; i, j = i+1, j-1 {
return pages
}
+// ByParam sorts the pages according to the given page Params key.
+//
+// Adjacent invocations on the same receiver with the same paramsKey will return a cached result.
+//
+// This may safely be executed in parallel.
+
func (p Pages) ByParam(paramsKey interface{}) Pages {
paramsKeyStr := cast.ToString(paramsKey)
key := "pageSort.ByParam." + paramsKeyStr