(values, default=None, empty_goes_last=True)
return map(str, order + end)
Use the __priority__ key to build a sorted list of config values.

    Parameters:
        default (None/int) (None): Default priority to use.
        empty_goes_last (bool) (True): If no priority should be put at the end.
            If set to False, then no priority will take the first gap available instead.
    
    Returns:
        List of str config values.
Use the __priority__ key to build a sorted list of config values.
Use the __priority__ key to build a sorted list of config values .
def _get_priority_order(values, default=None, empty_goes_last=True):
    """Use the __priority__ key to build a sorted list of config values.

    Parameters:
        default (None/int) (None): Default priority to use.
        empty_goes_last (bool) (True): If no priority should be put at the end.
            If set to False, then no priority will take the first gap available instead.
    
    Returns:
        List of str config values.
    """
    #Build dict of values grouped by priority
    priorities = {}
    for k, v in iteritems(values):
        is_str = isinstance(k, str)
        if not isinstance(k, str) or not k.startswith('_'):

            #Use key as default if key is a number
            if isinstance(k, (int, float)):
                _default = k
            else:
                _default = default

            #Get the priority if a dict, otherwise use default
            try:
                priority = v.get('__priority__', _default)
            except AttributeError:
                priority = _default
                
            try:
                priorities[priority].append(k)
            except KeyError:
                priorities[priority] = [k]
                
    #Build list of sorted values
    try:
        current = min(i for i in priorities if i is not None)
    except ValueError:
        current = 0
    order = []
    end = []
    while priorities:
        try:
            order += sorted(priorities.pop(current))
        except KeyError:
            try:
                if empty_goes_last:
                    end = sorted(priorities.pop(None))
                else:
                    order += sorted(priorities.pop(None))
            except KeyError:
                pass
        current += 1
    return map(str, order + end)
def _get_priority_order ( values , default = None , empty_goes_last = True ) : #Build dict of values grouped by priority priorities = { } for k , v in iteritems ( values ) : is_str = isinstance ( k , str ) if not isinstance ( k , str ) or not k . startswith ( '_' ) : #Use key as default if key is a number if isinstance ( k , ( int , float ) ) : _default = k else : _default = default #Get the priority if a dict, otherwise use default try : priority = v . get ( '__priority__' , _default ) except AttributeError : priority = _default try : priorities [ priority ] . append ( k ) except KeyError : priorities [ priority ] = [ k ] #Build list of sorted values try : current = min ( i for i in priorities if i is not None ) except ValueError : current = 0 order = [ ] end = [ ] while priorities : try : order += sorted ( priorities . pop ( current ) ) except KeyError : try : if empty_goes_last : end = sorted ( priorities . pop ( None ) ) else : order += sorted ( priorities . pop ( None ) ) except KeyError : pass current += 1 return map ( str , order + end )