From 61b023f5dfe796c7ba8183292853f01817016d14 Mon Sep 17 00:00:00 2001 From: George Goldberg Date: Tue, 24 Oct 2017 19:27:15 +0100 Subject: PLT-7822: Fix search order for SQL search backend. (#7704) --- model/post_list.go | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'model/post_list.go') diff --git a/model/post_list.go b/model/post_list.go index b3caadafd..018f7d14f 100644 --- a/model/post_list.go +++ b/model/post_list.go @@ -6,6 +6,7 @@ package model import ( "encoding/json" "io" + "sort" ) type PostList struct { @@ -82,6 +83,12 @@ func (o *PostList) Extend(other *PostList) { } } +func (o *PostList) SortByCreateAt() { + sort.Slice(o.Order, func(i, j int) bool { + return o.Posts[o.Order[i]].CreateAt > o.Posts[o.Order[j]].CreateAt + }) +} + func (o *PostList) Etag() string { id := "0" -- cgit v1.2.3-1-g7c22