def parse_input(args, condition=True):
    _args = []
    _kwargs = {}
    for arg in args:
        if isinstance(arg, six.string_types):
            arg_name, arg_value = parse_kwarg(arg)
            if arg_name:
                _kwargs[arg_name] = yamlify_arg(arg_value)
            else:
                _args.append(yamlify_arg(arg))
        elif isinstance(arg, dict):
            # Yes, we're popping this key off and adding it back if
            # condition_input is called below, but this is the only way to
            # gracefully handle both CLI and API input.
            if arg.pop('__kwarg__', False) is True:
                for key, val in six.iteritems(arg):
                    _kwargs[key] = yamlify_arg(val)
            else:
                _args.append(arg)
        else:
            _args.append(arg)
    if condition:
        return condition_input(_args, _kwargs)
    return _args, _kwargs
Recursively sort a nested dict.
dataset/ETHPy150Open saltstack/salt/salt/utils/args.py/parse_input--crossover with--dataset/ETHPy150Open apache/libcloud/contrib/scrape-ec2-prices.py/sort_nested_dict