Re: [go-nuts] How can i sort array inside struct

2016-12-19 Thread sergien . evgeny
Thanks a lot! I've tried pass pointers, but i forgot to pass & in Sort method. вторник, 20 декабря 2016 г., 0:24:14 UTC+5 пользователь Jan Mercl написал: > > > On Mon, Dec 19, 2016 at 8:16 PM > wrote: > > > This code does not do anything. > > The code does sort the array.

Re: [go-nuts] How can i sort array inside struct

2016-12-19 Thread Jan Mercl
On Mon, Dec 19, 2016 at 8:16 PM wrote: > This code does not do anything. The code does sort the array. It's just the copy of the array passed to sort.Sort that's get sorted. That's because array is a plain old value type. A pointer receiver methods fix it:

[go-nuts] How can i sort array inside struct

2016-12-19 Thread sergien . evgeny
This code does not do anything. package main import ( "fmt" "sort" ) type coll struct{ arr [4]int } func (c coll) Len() int{ return len(c.arr) } func (c coll) Less(i,j int) bool{ return c.arr[i]