I'am trying to implement a custom sort, a schema of my probleme :
Here my current sort function :
func (input Input) Sort() *[]string {
if input.Media == nil {
return new([]string)
}
var items []string
for _, media := range input.Media {
if media.IsPrincipal && len(items) < LimitedAmountItems {
items = append(items, media.URL)
}
}
for _, media := range input.Media {
if !media.IsPrincipal && len(items) < LimitedAmountItems {
items = append(items, media.URL)
}
}
return &items
}
You can find a full implementation here : https://play.golang.org/p/IoRf0CEfgKY
Any idea on how can I reduce the complexity of this function ?