In short the question is how can we find inside compare
method of Comparator
implementation whether sort order is ascending
(simple) or descending
(reversed). One method I found is to place instanceof check for ReverseOrder
class. But that is highly unreliable, as there are many implementations of Comparator
class for reverse order.
In other words, what if we have to write a comparator, which should not allow reversed(or descending) order.