I have two classes, let's say DerivedOne and DerivedTwo, derived from a base class Base.
Assuming I have these:
DerivedOne d1;
DerivedTwo d2;
when I compare d1 and d2, I'd like d1 to always be smaller, in other words an object of DerivedOne should have a higher priority than an object of DerivedTwo. What is the best/nicest way to do that?
I do not know if this is the nicest, but I would recommend using the instanceof operator inside the comparator.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With