turnage / graw

Golang Reddit API Wrapper
MIT License
288 stars 49 forks source link

How to sort a harvest by newest? #56

Closed emmggi closed 4 years ago

emmggi commented 4 years ago

I've tried in a few different ways. Like for example:

mp := make(map[string]string)
harvest, err := bot.ListingWithParams("/" + rippingType + "/" + rippingIdentifier, mp)
mp["after"] = lastPostId
mp["sort"] = "newest" (as well as "new")

then saw in the rsort package there is a Sorter struct then tried this:

type Sorter interface {
    Sort(h reddit.Harvest) []string
}

var p Sorter
newHarvest := Sorter.Sort(p, harvest)

and

type Sorter interface {
    Sort(h reddit.Harvest) []string
}
newSorter := reddit.Sorter.New()
newHarvest := Sorter.Sort(newSorter, harvest)

but of course i'm missing something here as well. Unless you can't sort a listing?