aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--backend/main.go5
1 files changed, 5 insertions, 0 deletions
diff --git a/backend/main.go b/backend/main.go
index c7a463e..eb6d70b 100644
--- a/backend/main.go
+++ b/backend/main.go
@@ -9,6 +9,7 @@ import (
"net/http"
"net/url"
"os"
+ "sort"
"strings"
"sync"
"time"
@@ -311,6 +312,10 @@ func postsHandler(w http.ResponseWriter, r *http.Request) {
return
}
+ sort.Slice(posts, func(i, j int) bool {
+ return posts[i].CreatedAt.After(posts[j].CreatedAt)
+ })
+
logger.Debug("successfully fetched posts", "number", len(posts))
w.Header().Set("Access-Control-Allow-Origin", "*")