def METHOD_NAME(packages: Iterable[AnyPackageDataMinimal]) -> list[AnyPackageDataMinimal]:
    def compare(p1: AnyPackageDataMinimal, p2: AnyPackageDataMinimal) -> int:
        if p1.visiblename < p2.visiblename:
            return -1
        if p1.visiblename > p2.visiblename:
            return 1
        return -package_version_compare(p1, p2)
    return sorted(packages, key=cmp_to_key(compare))