How does \Magento\Eav\Model\Entity\AbstractEntity::getSortedAttributes() work?

Context: How does \Magento\Catalog\Model\Product\Type\AbstractType::getSetAttributes() work?

Details: How does \Magento\Eav\Model\Entity\Attribute\Set.php::addSetInfo() work?

Details: How does \Magento\Eav\Model\Entity\Attribute\AbstractAttribute::isInSet() work?

Details: How does \Magento\Eav\Model\Entity\AbstractEntity::attributesCompare() work?