Skip to content

Operation sort

Iván Corrales Solera edited this page Dec 2, 2018 · 1 revision

stream.Sort

It sorts the elements in the stream b the given function

Example

package main

import (
  "fmt"
  "github.com/wesovilabs/koazee"
)

var stream = koazee.StreamOf([]int{2, 1, 4, 5, 3})

func main() {
    out := stream.Sort(func(x, y int) int {
      if x <= y {
        return -1
      }
      return 1
    }).Do()
    fmt.Println(out.Out().Val().([]int))
}

Download