def rank_similarities(similarities, restaurant_ids):
    """Combine similarities list with respective restaurant_ids, and rank them by similarity.

    Args:
        similarities (list): cosine similarities compared with target (first) restaurant
        restaurant_ids (list): restaurant_ids corresponding to similarities.

    Returns:
        similarities_ids (list): list of (similarity, id) tuple ranked by similarity.
    """
    similairties_ids = []
    similairties_array = similarities[0]

    for i in range(len(restaurant_ids)):
        similarity = similairties_array[i]
        id = restaurant_ids[i]
        # construct tuple with similarity first
        similairty_id = (similarity, id)
        similairties_ids.append(similairty_id)

    similairties_ids.sort(reverse=True)

    return similairties_ids