Skip to content

Instantly share code, notes, and snippets.

@ivancorrales
Created December 15, 2018 08:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ivancorrales/99b295ebfd4f31aea0c6ceb7f550e31f to your computer and use it in GitHub Desktop.
Save ivancorrales/99b295ebfd4f31aea0c6ceb7f550e31f to your computer and use it in GitHub Desktop.
stream.Sort / stream.Reverse
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