package main import "time" type ByPubDate []RssItem func (a ByPubDate) Len() int { return len(a) } func (a ByPubDate) Swap(i, j int) { a[i], a[j] = a[j], a[i] } func (a ByPubDate) Less(i, j int) bool { return parsePubDate(a[i].PubDate).After(parsePubDate(a[j].PubDate)) } func parsePubDate(pubDateStr string) time.Time { // Add the appropriate time parsing logic based on your date format // For example, if your date format is "Mon, 02 Jan 2006 15:04:05 -0700", // you can use the following parsing code parsedTime, _ := time.Parse("Mon, 02 Jan 2006 15:04:05 -0700", pubDateStr) return parsedTime }