Ask Mago to tidy up the product edit page and it reads the attribute set, proposes a logical order and rearranges it one group at a time, after you confirm each step.
Each change covers one group and waits for your OK on a card. The attributes you name come first; the other attributes of the group follow in their current order.
Before a system attribute moves to another group, the card asks for an extra acknowledgement.
It does not add attributes to a set or remove them, and it does not rename or delete groups. There is no copy of the old layout, so read the card before you confirm.
Requires Mago Core 1.1 or later. Using it needs the Magento_Catalog::sets permission.
composer require sparkable/magento-mago-attribute-setsbin/magento module:enable Sparkable_MagoAttributeSets && bin/magento setup:upgrade