Base comparator implementation.