Hello Srinivas
The traditional way to achieve this in go (as showcased
here and
here) is, to :
- declare a named type of slice
(each attribute age, name, sal, needs its own type declaration and 3 method implementations).
Since Go 1.8, we can achieve basically the same with much less boilerplate code (as showcased
here and
here) :
- implement 1 func "less" having type func(i, j int) bool
(each attribute age, name, sal, needs its own "less" func).
I suggest the latter.
HTH
Valentin