def rank_types(types):
    """
    Takes a list of binary numbers and returns a dictionary mapping each
    binary number to an integer indicating it's rank within the list.

    This is basically the better alternative to cluster_types, that works
    in that perfect world where we have few enough types to represent each
    as its own color.
    """
    include_null = '0b0' in types
    sorted_types = deepcopy(types)
    for i in range(len(sorted_types)):
        sorted_types[i] = int(sorted_types[i], 2)
    sorted_types.sort()

    ranks = {}
    for t in types:
        ranks[t] = sorted_types.index(eval(t)) + int(not include_null)

    return ranks
Takes a list of binary numbers and returns a dictionary mapping each
    binary number to an integer indicating it's rank within the list.

    This is basically the better alternative to cluster_types, that works
    in that perfect world where we have few enough types to represent each
    as its own color.