[go-nuts] Re: Interface Literals

2018-04-08 Thread matthewjuran
Here’s a way to do a similar thing now: https://play.golang.org/p/CtEYUo6MuqN func main() { x := []int{5, 1, 4, 2, 3} sort.Sort(ClosureSort(func() int { return (len(x)) }, func(i, j int) bool { return x[i] < x[j] }, func(i, j int) { x[i], x[j] = x[j], x[i] }))

[go-nuts] Re: Interface Literals

2018-04-08 Thread kduda via golang-nuts
Seven years later, I had the same idea as Js. Before: type intslice []int func (x intslice) Len() int { return len(x) } func (x intslice) Less(i, j int) bool { return x[i] < x[j] } func (x intslice) Swap(i, j int) { x[i], x[j] = x[j], x[i] } func main() { x := intslice{5, 1, 4, 2, 3}