Derive comparator classes for generic types