Skip to content

Instantly share code, notes, and snippets.

@ivancorrales
Created January 13, 2019 18:45
Show Gist options
  • Save ivancorrales/50b5e8fd27250b039d000c03247834e7 to your computer and use it in GitHub Desktop.
Save ivancorrales/50b5e8fd27250b039d000c03247834e7 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"github.com/wesovilabs/koazee"
"koazee-examples-v2/model"
)
func main() {
album := model.Albums[0]
tracks := koazee.StreamOf(album.Songs).
Sort(func(l, r *model.Song) int {
if l.Title < r.Title {
return -1
}
return 1
}).Do().Out().Val().([]*model.Song)
fmt.Println("Print the tracks of a given album sorted alphabetically asc")
koazee.StreamOf(tracks).
ForEach(func(s *model.Song) {
fmt.Printf(" - %s\n", s.Title)
}).Do()
fmt.Println("\nPrint the tracks of a given album sorted alphabetically desc")
koazee.StreamOf(tracks).
Reverse().
ForEach(func(s *model.Song) {
fmt.Printf(" - %s\n", s.Title)
}).Do()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment