def ranks_dict(poset):
    """
    Return a dictionary `r_dict` with rank keys (in descending order, from supremum,
    i.e. `h.vertices()[0]`, to infimum, `h.vertices()[-1]`) and lists of indices of
    the vertices at that level, to be displayed from left to right, suitable to be
    passed as the `heights` argument to `poset.plot`.
    """
    h = poset.hasse_diagram()
    ranks = [poset.rank_function()(z) for z in h.vertices()]
    rank_set = set(ranks) # Note that this sorts the ranks ascending (reversed later)
    r_indices = [[i for i, r in enumerate(ranks) if r == s] for s in rank_set]
    r_dict = dict(reversed(list(zip(rank_set, r_indices))))
    return r_dict