Created
December 15, 2018 08:36
-
-
Save ivancorrales/99b295ebfd4f31aea0c6ceb7f550e31f to your computer and use it in GitHub Desktop.
stream.Sort / stream.Reverse
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" | |
"strings" | |
) | |
var animals = []string{"lynx", "dog", "cat", "monkey", "fox", "tiger", "lion"} | |
func main() { | |
fmt.Print("input: ") | |
fmt.Println(animals) | |
stream := koazee.StreamOf(animals) | |
fmt.Print("stream.Reverse(): ") | |
fmt.Println(stream.Reverse().Out().Val()) | |
fmt.Print("stream.Sort(strings.Compare): ") | |
fmt.Println(stream.Sort(strings.Compare).Out().Val()) | |
} | |
/** | |
go run main.go | |
input: [lynx dog cat monkey fox tiger lion] | |
stream.Reverse(): [lion tiger fox monkey cat dog lynx] | |
stream.Sort(strings.Compare): [cat dog fox lion lynx monkey tiger] | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment