Construct params list in order of given keys.
332466
def _construct_params(params, required_keys, opt_keys=None):
        
        try:
            params_list = [params.pop(key) for key in required_keys]
        except KeyError as e:
            raise MissingParameter(
                'Missing expected request parameter: %s' % e)
        if opt_keys:
            params_list.extend([params.pop(key)
                                for key in opt_keys if key in params])
        return '/'.join(str(p) for p in params_list)
726321
def as_params(self):
        
        params = {}
        if self.has_filters:
            params['$filter'] = self.get_filters()
        if self.has_order:
            params['$orderby'] = self.get_order()
        if self.has_selects:
            params['$select'] = self.get_selects()
        if self.has_expands:
            params['$expand'] = self.get_expands()
        if self._search:
            params['$search'] = self._search
            params.pop('$filter', None)
            params.pop('$orderby', None)
        return params
577155
def from_params(cls, params):
        
        key_fn = lambda x: id(x[1].owner)
        streams = []
        for _, group in groupby(sorted(params.items(), key=key_fn), key_fn):
            group = list(group)
            inst = [p.owner for _, p in group][0]
            if not isinstance(inst, param.Parameterized):
                continue
            names = [p.name for _, p in group]
            rename = {p.name: n for n, p in group}
            streams.append(cls(inst, names, rename=rename))
        return streams
333089
def service_param_string(params):
    """"""
    p = []
    k = []
    for param in params:
        name = fix_param_name(param['name'])
        if 'required' in param and param['required'] is True:
            p.append(name)
        else:
            if 'default' in param:
                k.append('{name}={default}'.format(name=name, default=param['default']))
            else:
                k.append('{name}=None'.format(name=name))
    p.sort(lambda a, b: len(a) - len(b))
    k.sort()
    a = p + k
    return ', '.join(a)
578551
def expr_order_key(expr):
    """"""
    if hasattr(expr, '_order_key'):
        return expr._order_key
    try:
        if isinstance(expr.kwargs, OrderedDict):
            key_vals = expr.kwargs.values()
        else:
            key_vals = [expr.kwargs[key] for key in sorted(expr.kwargs)]
        return KeyTuple((expr.__class__.__name__, ) +
                        tuple(map(expr_order_key, expr.args)) +
                        tuple(map(expr_order_key, key_vals)))
    except AttributeError:
        return str(expr)
603573
public static void arrangeKeys(ArrayList<String> keys) {
    move(keys, "timestamp", 0);
    move(keys, "hostname", 1);
    move(keys, "type", 2);
  }
958984
def _build_param_string(params):
        
        pairs = []
        for key, value in params.iteritems():
            if value is None:
                value = ''
            pairs.append('{0}={1}'.format(key, value))
        if len(pairs) > 0:
            return '?{0}'.format('&'.join(pairs))
        return ''
360676
def _dict_key_priority(s):
        """"""
        if isinstance(s, Hook):
            return _priority(s._schema) - 0.5
        if isinstance(s, Optional):
            return _priority(s._schema) + 0.5
        return _priority(s)
418611
def _build_parmlist(self, parameters):
        

        args = []
        for key, value in parameters.items():
            if not value is None:
                # We always use the explicit-length keyname format, to reduce the chance
                # of requests failing due to unusual characters in parameter values.

                try:
                    classinfo = unicode
                except NameError:
                    classinfo = str

                if isinstance(value, classinfo):
                    key = '%s[%d]' % (key.upper(), len(value.encode('utf-8')))
                else:
                    key = '%s[%d]' % (key.upper(), len(str(value)))
                args.append('%s=%s' % (key, value))
        args.sort()
        parmlist = '&'.join(args)        
        return parmlist
786990
def _sorted_keys_items(dobj):
    """"""
    keys = sorted(dobj.keys())
    for key in keys:
        yield key, dobj[key]
811513
def get_ordered_params(url):
        

        if url not in URLHelper.__cache:
            URLHelper.__cache[url] = urlparse(url)

        params = URLHelper.query_string_to_dict(URLHelper.__cache[url].query)

        return OrderedDict(sorted(params.items()))
225338
def define_parameters(**parameters):
    """"""
    params = []
    for key, value in parameters.items():
        param = dict(ParameterKey=key, ParameterValue=value)
        params.append(param)
    return params
870641
def _make_sql_params(self,kw):
        """"""
        return ['%s=?' %k for k in kw.keys() ]
        for k,v in kw.iteritems():
            vals.append('%s=?' %k)
        return vals
480694
def keys(self, start=None, stop=None):
        """"""
        return (item[0] for item in self.items(start, stop))
954994
def _ordered(generator, *args, **kwargs):
    """"""
    unordered_dict = {k: v for k, v in generator(*args, **kwargs)}
    keys = sorted(list(dict(unordered_dict).keys()))
    result = OrderedDict()
    for key in keys:
        result[key] = unordered_dict[key]

    return result
968494
def flatten_params(self, data, base_key=None):
        
        result = {}

        if data is None:
            return result

        map_data = None
        if not isinstance(data, collections.Mapping):
            map_data = []
            for idx, val in enumerate(data):
                map_data.append([str(idx), val])
        else:
            map_data = list(data.items())

        for key, value in map_data:
            if not base_key is None:
                key = base_key + "[" + key + "]"

            if isinstance(value, basestring) or not hasattr(value, "__iter__"):
                result[key] = value
            else:
                result.update(self.flatten_params(value, key))

        return result
468453
def order_params desc = !desc?
      p = grid.params.dup
      if ordered?
        p[:desc] = desc
      else
        p = p.merge order: name, desc: desc 
      end
      grid.scoped_params p
    end