[TASK] Keep the changes to PackageStates.php low

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.

Resolves: #56362
Releases: 6.3, 6.2
Change-Id: Id6cc4cc2d3f4d9f00e90f355bdede1afe20f57af
Reviewed-on: http://review.typo3.org/31774
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>