Created
January 13, 2019 18:45
-
-
Save ivancorrales/50b5e8fd27250b039d000c03247834e7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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