Adding Type Parameters to Struct Types

Understand how we can utilize generics when dealing with type parameters in Go.

Earlier, we wrote a generic function for sorting slices called SortSlice(), but that has some limitations in that it can only handle slices that are based on types that meet the constraints in constraints.Ordered. Oftentimes, we might want to handle slices that might contain types based on struct, say, for example, this type:

Get hands-on with 1200+ tech skills courses.