Super Attribute Position on Product Page Magento 1

I check the magento collection.php thank you @magefms

    /**
     * Set order collection by Position
     *
     * @param string $dir
     * @return Mage_Catalog_Model_Resource_Product_Type_Configurable_Attribute_Collection
     */
    public function orderByPosition($dir = self::SORT_ORDER_ASC)
    {
        $this->setOrder('position ',  $dir);
        return $this;
    }

Lucky for me my Attribute created at the same time so i achieve what i want Ijust change

  public function orderByPosition($dir = self::SORT_ORDER_DESC)

thanks


Try this fix:
Copy the file

app/code/core/Mage/Catalog/Model/Resource/Product/Type/Configurable/Attribute/Collection.php

to local folder

app/code/local/Mage/Catalog/Model/Resource/Product/Type/Configurable/Attribute/Collection.php  

Please add the following code in line 305

$sortOrder = 1;
foreach ($this->_items as $item) {
$productAttribute = $item->getProductAttribute();
if (!($productAttribute instanceof Mage_Eav_Model_Entity_Attribute_Abstract)) {
Continue;
}
$options = $productAttribute->getFrontend()->getSelectOptions();
foreach ($options as $option) {
if (!$option['value']) continue;
                    if (isset($values[$item->getId() . ':' . $option['value']])) {
                            $values[$item->getId() . ':' . $option['value']]['order'] = $sortOrder++;
                    }
            }
}
usort($values, function($a, $b) {
return $a['order'] - $b['order'];
});  

The code given should be placed above the code of Magento shown below:

foreach ($values as $data) {

$this->getItemById($data[‘product_super_attribute_id’])->addPrice($data);

}  

After the above changes, clear the cache and check if it works.