4 ms·
Note 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
by Merovius 4y ago
Note 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.