1
0
mirror of https://github.com/taigrr/wtf synced 2025-01-18 04:03:14 -08:00
wtf/modules/pocket/item_service.go
2019-11-10 13:59:20 +01:00

20 lines
469 B
Go

package pocket
import "sort"
type sortByTimeAdded []Item
func (a sortByTimeAdded) Len() int { return len(a) }
func (a sortByTimeAdded) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a sortByTimeAdded) Less(i, j int) bool { return a[i].TimeAdded > a[j].TimeAdded }
func orderItemResponseByKey(response ItemLists) []Item {
var items sortByTimeAdded
for _, v := range response.List {
items = append(items, v)
}
sort.Sort(items)
return items
}