'Compare two entities and return their relative order.
Compares self to that based on the current sort orderings and the
key orders between them. Returns negative, 0, or positive depending on
whether self is less, equal to, or greater than that. This
comparison returns as if all values were to be placed in ascending order
(highest value last).  Only uses the sort orderings to compare (ignores
keys).
Args:
that: SortOrderEntity
Returns:
Negative if self < that
Zero if self == that
Positive if self > that'

def CmpProperties(self, that):

    if (not self.__entity):
        return cmp(self.__entity, that.__entity)
    for (identifier, order) in self.__orderings:
        value1 = self.__GetValueForId(self, identifier, order)
        value2 = self.__GetValueForId(that, identifier, order)
        result = cmp(value1, value2)
        if (order == Query.DESCENDING):
            result = (- result)
        if result:
            return result
    return 0
