(attrs, object)
Sort the attrs list in-place by _fields and then alphabetically by name
Sort the attrs list in-place by _fields and then alphabetically by name
Sort the attrs list in - place by _fields and then alphabetically by name
def sort_attributes(attrs, object):
    'Sort the attrs list in-place by _fields and then alphabetically by name'
    # This allows data descriptors to be ordered according
    # to a _fields attribute if present.
    fields = getattr(object, '_fields', [])
    try:
        field_order = {name : i-len(fields) for (i, name) in enumerate(fields)}
    except TypeError:
        field_order = {}
    keyfunc = lambda attr: (field_order.get(attr[0], 0), attr[0])
    attrs.sort(key=keyfunc)
def sort_attributes ( attrs , object ) : # This allows data descriptors to be ordered according # to a _fields attribute if present. fields = getattr ( object , '_fields' , [ ] ) try : field_order = { name : i - len ( fields ) for ( i , name ) in enumerate ( fields ) } except TypeError : field_order = { } keyfunc = lambda attr : ( field_order . get ( attr [ 0 ] , 0 ) , attr [ 0 ] ) attrs . sort ( key = keyfunc )