'Given a list of MongoEngine-style sort keys, return a list
of sorting tuples that can be applied to a PyMongo cursor. For
example:
>>> qs._get_order_by([\'-last_name\', \'first_name\'])
[(\'last_name\', -1), (\'first_name\', 1)]'

def _get_order_by(self, keys):

    key_list = []
    for key in keys:
        if (not key):
            continue
        if (key == '$text_score'):
            key_list.append(('_text_score', {'$meta': 'textScore'}))
            continue
        direction = pymongo.ASCENDING
        if (key[0] == '-'):
            direction = pymongo.DESCENDING
        if (key[0] in ('-', '+')):
            key = key[1:]
        key = key.replace('__', '.')
        try:
            key = self._document._translate_field_name(key)
        except Exception:
            pass
        key_list.append((key, direction))
    return key_list
