'Parse a sort key query param from the request object.'

def _get_sort_key(self, req):

    sort_key = req.params.get('sort_key', 'created_at')
    if ((sort_key is not None) and (sort_key not in SUPPORTED_SORT_KEYS)):
        _keys = ',    '.join(SUPPORTED_SORT_KEYS)
        msg = (_('Unsupported    sort_key.    Acceptable    values:    %s') % (_keys,))
        raise exc.HTTPBadRequest(explanation=msg)
    return sort_key
