[BUGFIX] Sorting of packages by dependency

Implement proper dependency handling in Flow PackageManager.
The code ensures that all framework packages are loaded first.

Releases: 6.2
Resolves: #52828
Change-Id: I6717756efae28b1f8e13fc3a251328f69f54b4d4