mirror of
https://github.com/aljazceru/njump.git
synced 2025-12-17 22:34:25 +01:00
more efficient sorting.
This commit is contained in:
6
nostr.go
6
nostr.go
@@ -3,7 +3,6 @@ package main
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"sort"
|
||||
"time"
|
||||
|
||||
"github.com/nbd-wtf/go-nostr"
|
||||
@@ -163,10 +162,7 @@ func getLastNotes(ctx context.Context, code string) []*nostr.Event {
|
||||
})
|
||||
lastNotes := make([]*nostr.Event, 0, 20)
|
||||
for event := range events {
|
||||
lastNotes = append(lastNotes, event)
|
||||
lastNotes = nostr.InsertEventIntoDescendingList(lastNotes, event)
|
||||
}
|
||||
sort.Slice(lastNotes, func(i, j int) bool {
|
||||
return lastNotes[i].CreatedAt.Time().After(lastNotes[j].CreatedAt.Time())
|
||||
})
|
||||
return lastNotes
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user