Introduce a sort operation of the packages before determining
the loading order.
This way the number of changes made to the PackageStates.php file
are reduced.
This is only a first step, further improvements have to be made
to finally resolve #56362.