Expert: a FieldComparator compares hits so as to determine their
sort order when collecting the top results with TopFieldCollector. The concrete public FieldComparator
classes here correspond to the SortField types.

This API is designed to achieve high performance
sorting, by exposing a tight interaction with FieldValueHitQueue as it visits hits. Whenever a hit is
competitive, it's enrolled into a virtual slot, which is
an int ranging from 0 to numHits-1. The FieldComparator is made aware of segment transitions
during searching in case any internal state it's tracking
needs to be recomputed during these transitions.

setBottom(int) This method is called by
FieldValueHitQueue to notify the
FieldComparator of the current weakest ("bottom")
slot. Note that this slot may not hold the weakest
value according to your comparator, in cases where
your comparator is not the primary one (ie, is only
used to break ties from the comparators before it).

compareBottom(int) Compare a new hit (docID)
against the "weakest" (bottom) entry in the queue.

compareBottom

Compare the bottom of the queue with doc. This will
only invoked after setBottom has been called. This
should return the same result as compare(int,int)} as if bottom were slot1 and the new
document were slot 2.

For a search that hits many results, this method
will be the hotspot (invoked by far the most
frequently).

Parameters:

doc - that was hit

Returns:

any N < 0 if the doc's value is sorted after
the bottom entry (not competitive), any N > 0 if the
doc's value is sorted before the bottom entry and 0 if
they are equal.

value

compareValues

Returns -1 if first is less than second. Default
impl to assume the type implements Comparable and
invoke .compareTo; be sure to override this method if
your FieldComparator's type isn't a Comparable or
if your values may sometimes be null