Use Reverse and StableSort to sort items

This commit is contained in:
Peter Stuifzand 2018-03-29 17:50:57 +02:00
parent 92a23e7810
commit 6756527f31

View File

@ -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,