parameters: (attrs, object)
docstring: Sort the attrs list in-place by _fields and then alphabetically by name
docstring_summary: Sort the attrs list in-place by _fields and then alphabetically by name
docstring_tokens: Sort the attrs list in - place by _fields and then alphabetically by name
function: 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)
function_tokens: 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 )