'Process sorting params.
Currently glance supports two sorting syntax: classic and new one,
that is uniform for all OpenStack projects.
Classic syntax: sort_key=name&sort_dir=asc&sort_key=size&sort_dir=desc
New syntax: sort=name:asc,size:desc'

def _get_sorting_params(self, params):

    sort_keys = []
    sort_dirs = []
    if ('sort' in params):
        if (('sort_key' in params) or ('sort_dir' in params)):
            msg = _('Old    and    new    sorting    syntax    cannot    be    combined')
            raise webob.exc.HTTPBadRequest(explanation=msg)
        for sort_param in params.pop('sort').strip().split(','):
            (key, _sep, dir) = sort_param.partition(':')
            if (not dir):
                dir = self._default_sort_dir
            sort_keys.append(self._validate_sort_key(key.strip()))
            sort_dirs.append(self._validate_sort_dir(dir.strip()))
    else:
        while ('sort_key' in params):
            sort_keys.append(self._validate_sort_key(params.pop('sort_key').strip()))
        while ('sort_dir' in params):
            sort_dirs.append(self._validate_sort_dir(params.pop('sort_dir').strip()))
        if sort_dirs:
            dir_len = len(sort_dirs)
            key_len = len(sort_keys)
            if ((dir_len > 1) and (dir_len != key_len)):
                msg = _('Number    of    sort    dirs    does    not    match    the    number    of    sort    keys')
                raise webob.exc.HTTPBadRequest(explanation=msg)
    if (not sort_keys):
        sort_keys = [self._default_sort_key]
    if (not sort_dirs):
        sort_dirs = [self._default_sort_dir]
    return (sort_keys, sort_dirs)
