From bd3b4bee0b0ef881fc53e6e2aeae1f2f5ceca3fe Mon Sep 17 00:00:00 2001 From: Daniele Tonon Date: Wed, 12 Jul 2023 12:52:10 +0200 Subject: [PATCH] Sort profile notes by date --- nostr.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/nostr.go b/nostr.go index ed47382..6fed3fb 100644 --- a/nostr.go +++ b/nostr.go @@ -4,6 +4,7 @@ import ( "context" "fmt" "os" + "sort" "time" "github.com/dgraph-io/ristretto" @@ -163,5 +164,8 @@ func getLastNotes(ctx context.Context, code string) []*nostr.Event { for event := range events { lastNotes = append(lastNotes, event) } + sort.Slice(lastNotes, func(i, j int) bool { + return lastNotes[i].CreatedAt.Time().After(lastNotes[j].CreatedAt.Time()) + }) return lastNotes }