@Jan: that does not work; I used this example: http://nerdyworm.com/blog/2013/05/15/sorting-a-slice-of-structs-in-go/
@xao: slight change: when using sort.Sort(Courses(courses)) it does work! Thanks to you both! Here is the working version: https://play.golang.org/p/GZXzM4ghNX 2016-09-20 22:14 GMT+02:00 xingtao zhao <[email protected]>: > Or: > > sort.Sort(Courses(course)) > > On Tuesday, September 20, 2016 at 10:50:15 AM UTC-7, Jan Mercl wrote: >> >> Types []Course and Courses are distinct types. courses have type >> []Courses because that's what the parameter to make is. Change it to >> Courses, ie. >> >> courses := make(Courses, maxrow) >> >> On Tue, Sep 20, 2016, 19:44 Arie van Wingerden <[email protected]> wrote: >> >>> Hi, >>> >>> Still a beginner ... first take at a bit more difficult thing. >>> >>> I cannot get this https://play.golang.org/p/qgBLH0r_vq to work. >>> >>> Compiler says: >>> cannot use courses (type []Course) as type sort.Interface in argument to >>> sort.Sort: >>> []Course does not implement sort.Interface (missing Len method) >>> >>> However, I thought I need the Len method for []Courses instead of >>> []Course! >>> >>> Pleas help. >>> >>> TIA >>> >>> -- >>> 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 [email protected]. >>> For more options, visit https://groups.google.com/d/optout. >>> >> -- >> >> -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 [email protected]. For more options, visit https://groups.google.com/d/optout.
