<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def atlas_rank_peers_by_data_availability( peer_list=None, peer_table=None, local_inv=None, con=None, path=None ):
 """ Get a ranking of peers to contact for a zonefile. Peers are ranked by the number of zonefiles they have which we don't have. This is used to select neighbors. """


    with AtlasPeerTableLocked(peer_table) as ptbl:
        if peer_list is None:
            peer_list = ptbl.keys()[:]

        if local_inv is None:
            # what's my inventory?
            inv_len = atlasdb_zonefile_inv_length( con=con, path=path )
            local_inv = atlas_make_zonefile_inventory( 0, inv_len, con=con, path=path )

        peer_availability_ranking = []    # (health score, peer hostport)
        for peer_hostport in peer_list:

            peer_inv = atlas_peer_get_zonefile_inventory( peer_hostport, peer_table=ptbl )

            # ignore peers that we don't have an inventory for
            if len(peer_inv) == 0:
                continue

            availability_score = atlas_inventory_count_missing( local_inv, peer_inv )
            peer_availability_ranking.append( (availability_score, peer_hostport) )
    

    # sort on availability
    peer_availability_ranking.sort()
    peer_availability_ranking.reverse()

    return [peer_hp for _, peer_hp in peer_availability_ranking]