'Returns a ranked list of vhosts from vhost_list that match target_name.
The ranking gives preference to SSL vhosts.
:param list vhost_list: list of vhosts to filter and rank
:param str target_name: The name to match
:returns: list of dicts containing the vhost, the matching name, and
the numerical rank
:rtype: list'

def _rank_matches_by_name_and_ssl(self, vhost_list, target_name):

    matches = []
    for vhost in vhost_list:
        (name_type, name) = parser.get_best_match(target_name, vhost.names)
        if (name_type == 'exact'):
            matches.append({'vhost': vhost, 'name': name, 'rank': (0 if vhost.ssl else 1)})
        elif (name_type == 'wildcard_start'):
            matches.append({'vhost': vhost, 'name': name, 'rank': (2 if vhost.ssl else 3)})
        elif (name_type == 'wildcard_end'):
            matches.append({'vhost': vhost, 'name': name, 'rank': (4 if vhost.ssl else 5)})
        elif (name_type == 'regex'):
            matches.append({'vhost': vhost, 'name': name, 'rank': (6 if vhost.ssl else 7)})
    return sorted(matches, key=(lambda x: x['rank']))
