Sort attributes of each element
519185
@Override
    public void processElement(Wrapper<Element> elementWrapper) {
        Element element = elementWrapper.getContent();
        element.setAttributes(getSortedAttributes(element));
    }
1201363
def attributes(attrs):
    
    attrs = attrs or {}
    ident = attrs.get("id", "")
    classes = attrs.get("classes", [])
    keyvals = [[x, attrs[x]] for x in attrs if (x != "classes" and x != "id")]
    return [ident, classes, keyvals]
37666
function renderAttributes(ns, node, attrs) {
  let map = ATTRIBUTE_MAP[ns] || {};
  keys(map).forEach(key => {
    let attrKey = map[key];
    if(key in attrs) {
      node.setAttribute(attrKey, attrs[key]);
    }
  });
}
1211911
function mergeAttributes(from, to) {
    mergeClassNames(from, to);

    // It’s important to preserve attributes order: ones in `from` have higher
    // priority than in `to`. Collect attributes in map in order they should
    // appear in `to`
    const attrMap = new Map();

    let attrs = from.attributes;
    for (let i = 0; i < attrs.length; i++) {
        attrMap.set(attrs[i].name, attrs[i].clone());
    }

    attrs = to.attributes.slice();
    for (let i = 0, attr, a; i < attrs.length; i++) {
        attr = attrs[i];
        if (attrMap.has(attr.name)) {
            a = attrMap.get(attr.name);
            a.value = attr.value;

            // If user explicitly wrote attribute in abbreviation, it’s no longer
            // implied and should be outputted even if value is empty
            if (a.options.implied) {
                a.options.implied = false;
            }
        } else {
            attrMap.set(attr.name, attr);
        }

        to.removeAttribute(attr);
    }

    const newAttrs = Array.from(attrMap.values());
    for (let i = 0; i < newAttrs.length; i++) {
        to.setAttribute(newAttrs[i]);
    }

    return to;
}
247968
def sort
      element_order = params.fetch "element_order"

      element_order.each_with_index do |element_id, index|
        element = Element.find_by_id element_id
        element.update_attribute :position, index+1
      end

      head :no_content
    end
1044341
function findAttributesPattern (priority, element, ignore) {
  const attributes = element.attributes
  const sortedKeys = Object.keys(attributes).sort((curr, next) => {
    const currPos = priority.indexOf(attributes[curr].name)
    const nextPos = priority.indexOf(attributes[next].name)
    if (nextPos === -1) {
      if (currPos === -1) {
        return 0
      }
      return -1
    }
    return currPos - nextPos
  })

  for (var i = 0, l = sortedKeys.length; i < l; i++) {
    const key = sortedKeys[i]
    const attribute = attributes[key]
    const attributeName = attribute.name
    const attributeValue = escapeValue(attribute.value)

    const currentIgnore = ignore[attributeName] || ignore.attribute
    const currentDefaultIgnore = defaultIgnore[attributeName] || defaultIgnore.attribute
    if (checkIgnore(currentIgnore, attributeName, attributeValue, currentDefaultIgnore)) {
      continue
    }

    var pattern = `[${attributeName}="${attributeValue}"]`

    if ((/\b\d/).test(attributeValue) === false) {
      if (attributeName === 'id') {
        pattern = `#${attributeValue}`
      }

      if (attributeName === 'class') {
        const className = attributeValue.trim().replace(/\s+/g, '.')
        pattern = `.${className}`
      }
    }

    return pattern
  }
  return null
}
178291
function getAttrs(element) {
  return Array.from(element.attributes).reduce((attrs, attr) => {
    attrs[attr.name] = attr.value;
    return attrs;
  }, {});
}
745652
def _attr_seq(self, attrs):
        
        attrs = attrs.strip()
        attr_lst = attrs.split()
        return sorted(attr_lst)
548732
def to_list(self):
        """"""

        ret = OrderedDict()
        for attrname in self.attrs:
            ret[attrname] = self.__getattribute__(attrname)
        return ret
1071323
def visit_attribute(self, node):
        """"""
        return "%s.%s" % (self._precedence_parens(node, node.expr), node.attrname)
626997
function findElementAttributeValue(attributeName, elems) {

    elems = Array.isArray(elems) ? elems : [ elems ];

    var value = elems.filter(function (elem) {
        return elem.attrib.name.toLowerCase() === attributeName.toLowerCase();
    }).map(function (filteredElems) {
        return filteredElems.attrib.value;
    }).pop();

    return value ? value : '';
}
1137382
function ( els, attrs, childAttr ) {
            var i, j, elNum = els.length, children, attrNum = attrs.length;
    
            for ( i = 0; i < elNum; ++i ) {
                var el = els[i];
    
                for ( j = 0; j < attrNum; ++j ) {
                    var prop =  attrs[j];
    
                    if ( $B( el ).attr( prop ) ) {
                        $B( el ).removeAttr( prop );
                    }
                }
    
                if ( childAttr ) {
                    children = el.children;
                    if ( children.length > 0 ) {
                        $B.utils.removeCustomAttribute( children, attrs, true );
                    }
                }
            }
        }
1092470
function setElAttributes(el, attributes) {
  Object.getOwnPropertyNames(attributes).forEach(function (attrName) {
    var attrValue = attributes[attrName];

    if (attrValue === null || typeof attrValue === 'undefined' || attrValue === false) {
      el.removeAttribute(attrName);
    } else {
      el.setAttribute(attrName, attrValue === true ? '' : attrValue);
    }
  });
}
1019092
function getDataAttributes(attributes) {
  if (!attributes) {
    return {};
  }

  return Object.keys(attributes).reduce((ret, key) => {
    ret[`data-${key.toLowerCase()}`] = attributes[key];
    return ret;
  }, {});
}
391984
def sorted(self, attrname, reverse=False):
        
        attrs = []
        for i, pseudo in self:
            try:
                a = getattr(pseudo, attrname)
            except AttributeError:
                a = np.inf
            attrs.append((i, a))

        # Sort attrs, and build new table with sorted pseudos.
        return self.__class__([self[a[0]] for a in sorted(attrs, key=lambda t: t[1], reverse=reverse)])
984664
def alphabetize_attributes(self):
        
        self.attributes.sort(key=lambda name: (name == self.class_attr_name, name))
164369
def attributes!(object, *attrs)
      attrs.each do |attr|
        method_missing attr, object.send(attr)
      end
    end