Changing sorting algorithm as per Allan points. VersionRange of fam_requires have the most weight, then if tie the one with the least packages, and if still tied , calculate the a weighted average of where the rest of the fam appear in all the variants, and sort by the version Range of those families. In case of a tie at this point sort using the remaining families alphabetically