Use Reverse and StableSort to sort items
This commit is contained in:
parent
92a23e7810
commit
6756527f31
|
@ -196,12 +196,14 @@ func (b *memoryBackend) TimelineGet(after, before, channel string) microsub.Time
|
|||
}
|
||||
}
|
||||
|
||||
sort.Slice(items, func(a, b int) bool {
|
||||
sort.SliceStable(items, func(a, b int) bool {
|
||||
timeA, _ := items[a]["published"].(string)
|
||||
timeB, _ := items[b]["published"].(string)
|
||||
return strings.Compare(timeB, timeA) > 0
|
||||
return strings.Compare(timeA, timeB) > 0
|
||||
})
|
||||
|
||||
items := sort.Reverse(items)
|
||||
|
||||
return microsub.Timeline{
|
||||
Paging: microsub.Pagination{},
|
||||
Items: items,
|
||||
|
|
Loading…
Reference in New Issue
Block a user