def _feature_value_count_comparator(a,
                                    b):
  """Compares two FeatureValueCount tuples."""
  # To keep the result deterministic, if two feature values have the same
  # number of appearances, the one with the 'larger' feature value will be
  # larger.
  return (a.count < b.count or
          (a.count == b.count and a.feature_value < b.feature_value))