'Initializer.
Args:
expression: An expression to be evaluated on each matching document
to sort by. The expression must evaluate to a text or numeric value.
The expression can simply be a field name, or some compound expression
such as "_score + count(likes) * 0.1" which will add the score from a
scorer to a count of the values of a likes field times 0.1. See
https://developers.google.com/appengine/docs/python/search/overview#Expressions
for a list of legal expressions.
direction: The direction to sort the search results, either ASCENDING
or DESCENDING
default_value: The default value of the expression. The default_value is
returned if expression cannot be calculated, for example, if the
expression is a field name and no value for that named field exists.
A text value must be specified for text sorts. A numeric value must be
specified for numeric sorts. A date value must be specified for date
sorts.
Raises:
TypeError: If any of the parameters has an invalid type, or an unknown
attribute is passed.
ValueError: If any of the parameters has an invalid value.
ExpressionError: If the expression string is not parseable.'

def __init__(self, expression, direction=DESCENDING, default_value=None):

    self._expression = _ConvertToUnicode(expression)
    self._direction = self._CheckDirection(direction)
    if (self._expression is None):
        raise TypeError('expression    must    be    a    SortExpression,    got    None')
    _CheckExpression(self._expression)
    self._default_value = default_value
    if (self._default_value is not None):
        if isinstance(self.default_value, basestring):
            self._default_value = _ConvertToUnicode(default_value)
            _CheckText(self._default_value, 'default_value')
        elif (not isinstance(self._default_value, (int, long, float, datetime.date, datetime.datetime))):
            raise TypeError(('default_value    must    be    text,    numeric    or    datetime,    got    %s' % self._default_value.__class__.__name__))
