From 75f6db76bdbf8846b58d86951e0bebf8bd4b8a3a Mon Sep 17 00:00:00 2001 From: Guillermo Serrahima Date: Sat, 21 Mar 2026 03:17:46 +0100 Subject: sorted posts chronologically --- backend/main.go | 5 +++++ 1 file changed, 5 insertions(+) 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", "*") -- cgit v1.2.3