def normalize_attributes(xml):
    """Sort XML attributes to make it easier to find differences"""
    for node in xml.iterfind(".//*"):
        if node.attrib:
            attrs = sorted(node.attrib.items())
            node.attrib.clear()
            node.attrib.update(attrs)
    return xml