3 ms·
I don't program in Go. But I could imagine that I might at some point want to sort a list of a custom struct by one of its members. And that's probably as advan
by avgcorrection 4y ago
I don't program in Go. But I could imagine that I might at some point want to sort a list of a custom struct by one of its members. And that's probably as advanced as it would get for my purposes.
- Merovius 4y agoNote that the article targets people writing generic code, not consuming it. So it's not really about what you want to sort. It's about what (and how) you want to support with your sorting algorithm. As for that use-case: Go generics currently don't have a way to constrain on struct fields. So that will always have to be done with some sort of custom comparison function written by the user of your code, which returns the appropriate field.