I will not give you the final solution but I will direct you to a place where you change the default behaviour.
So, if the attribute does not have a custom source it uses default source class which is
\Magento\Eav\Model\Entity\Attribute\Source\Table. All of the attribute options are returned in a function
getAllOptions($withEmpty, $defaultValues). If you check it, you will find that in this function an
attributeOptionCollection is created on which a function
setPositionOrder($dir, $sortAlpha) is called. In this function we have hardcoded sort order of the options collection -
I can give you quick 2 options to make it work as you want it:
- make a before plugin on
\Magento\Eav\Model\ResourceModel\Entity\Attribute\Option\Collection::setPositionOrder and change the
$sortAlpha variable to
true - I am not sure how the sorting will behave, but it should be alphabeticaly
- make and around/after plugin on
\Magento\Eav\Model\ResourceModel\Entity\Attribute\Option\Collection::setPositionOrder and change the sorting the way you want
There are of course more options, you can also make plugins for
\Magento\Eav\Model\Entity\Attribute\Source\Table::getAllOptions as well as you can override it (which I do not reccomend). Let me know which option you selected and good luck!