Skip to content

Instantly share code, notes, and snippets.

@iFurySt
Created July 26, 2023 13:00
Show Gist options
  • Save iFurySt/dc2beecf4f491e656cc1c4abed27e2bd to your computer and use it in GitHub Desktop.
Save iFurySt/dc2beecf4f491e656cc1c4abed27e2bd to your computer and use it in GitHub Desktop.
Sort a slice with generic type in Go.
package main
import (
"fmt"
"github.com/ifuryst/lol"
"golang.org/x/exp/slices"
"math"
)
func main() {
s := lol.MergeSlice([]float64{5, 1, math.NaN(), 2, 4, math.NaN(), 9})
slices.Sort(s)
fmt.Println(s)
// Output:
// [NaN NaN 1 2 4 5 9]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment