I have same issue just today and able to fix it by changing each attribute key as string by adding any character like "_" in the getJsonConfig result. It seems its a browser or javascript issue where it automatically sort numeric array keys so changing it to string key will prevent it from sorting automatically.
Testing Solution:
1. Edit vendor\magento\module-swatches\Block\Product\Renderer\Configurable.php
2. Add the below function to override the getJsonConfig:
public function getJsonConfig() {
$jsonConfig = parent::getJsonConfig();
$decodedConfig = json_decode($jsonConfig, true);
foreach ($decodedConfig['attributes'] as $attributeId => $attributeData) {
$decodedConfig['attributes']["_" . $attributeId] = $attributeData;
unset($decodedConfig['attributes'][$attributeId]);
}
return $this->jsonEncoder->encode($decodedConfig);
}
You have two choices, either use plugin or extend that file. I use plugin for this.
Hope that helps :)