Skip to content

Instantly share code, notes, and snippets.

@geraldstanje geraldstanje/main.go
Created Feb 21, 2017

Embed
What would you like to do?
sorting in go 1.8
package main
import (
"fmt"
"sort"
)
func tokensByAscending(t []int) func(i, j int) bool {
return func(i, j int) bool {
return t[i] < t[j]
}
}
func main() {
tokens := []int{
1,
2,
44123,
8,
3,
2,
99,
6,
}
sort.Slice(tokens, tokensByAscending(tokens))
fmt.Println(tokens)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.