mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
20 lines
469 B
Go
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
|
|
}
|