I have an abstract class named Time
, then two subclasses SingleYear
and Period
. I could have more subclasses later on.
The Time
class implements IComparable
, but the CompareTo
function is actually implemented in each subclass.
I have a query in linq, like this: myListOfObjects.OrderBy(o=>o.Time);
That is working.
However, I'd like to be able to choose whether SingleYear
or Period
objects should come first (before the actual CompareTo
). My implementation of CompareTo
is correct, however in some cases I need to show first Periods, then Single Years (or vice-versa).
Since I can have more (let's say 5-6) subclasses, how am I able to specify which subclasses should come first, then CompareTo will do it's work afterwards?