Hi Jan, I am still unable to understand why is the contract broken? The "magnitude" of each entry in "indexes" slice is defined by less func in a consistent way. What exactly am I doing incorrect here? If I changed the program to create structs
type entry struct { rating int index int } And then create slice of these structs and defined less() based on rating, would it change anything conceptually? On Thu, Nov 9, 2017 at 5:54 PM, Jan Mercl <0xj...@gmail.com> wrote: > On Thu, Nov 9, 2017 at 1:17 PM gaurav <gauravagarw...@gmail.com> wrote: > > > I must be missing something basic here: a simple usage of sort.Slice is > not sorting the slice correctly for me. I must be missing something very > basic here; could someone please check this out? > > The less test is perfomed on the ratings slice, but the item swap is > perfomed on the indexes slice. This breaks the contract of SortSlice and it > cannot work. > > -- > > -j > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.