'Compares the given values taking into account any filters.
This function can be used as the cmp argument for list.sort() and sorted().
This function is slightly more efficient that Order.key when comparing two
entities, however it is much less efficient when sorting a list of entities.
Args:
lhs: An entity_pb.EntityProto
rhs: An entity_pb.EntityProto
filter_predicate: A FilterPredicate used to prune values before comparing
entities or None.
Returns:
An integer <, = or > 0 representing the operator that goes in between lhs
and rhs that to create a true statement.'

def cmp(self, lhs, rhs, filter_predicate=None):

    names = self._get_prop_names()
    if (filter_predicate is not None):
        names |= filter_predicate._get_prop_names()
    lhs_value_map = _make_key_value_map(lhs, names)
    rhs_value_map = _make_key_value_map(rhs, names)
    if (filter_predicate is not None):
        filter_predicate._prune(lhs_value_map)
        filter_predicate._prune(rhs_value_map)
    result = self._cmp(lhs_value_map, rhs_value_map)
    if result:
        return result
    if ((not lhs.has_key()) and (not rhs.has_key())):
        return 0
    lhs_key = (lhs_value_map.get(datastore_types.KEY_SPECIAL_PROPERTY) or datastore_types.ReferenceToKeyValue(lhs.key()))
    rhs_key = (rhs_value_map.get(datastore_types.KEY_SPECIAL_PROPERTY) or datastore_types.ReferenceToKeyValue(rhs.key()))
    return cmp(lhs_key, rhs_key)
