mirror of
https://github.com/aljazceru/njump.git
synced 2025-12-18 14:54:24 +01:00
more efficient sorting.
This commit is contained in:
6
nostr.go
6
nostr.go
@@ -3,7 +3,6 @@ package main
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"sort"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/nbd-wtf/go-nostr"
|
"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)
|
lastNotes := make([]*nostr.Event, 0, 20)
|
||||||
for event := range events {
|
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
|
return lastNotes
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user