def discrete_hist(l, cutoff=10, max=100):

    """
    Return dict with elements in l as keys, counts as values, sorted by highest count
    Drop low cts
    """
    d = dict()

    for e in l:
        if e not in d:
            d[e] = 1
        else:
            d[e] += 1

    d = {
        k: v
        for i, (k, v) in enumerate(
            sorted(d.items(), key=lambda item: item[1], reverse=True)
        )
        if (max is None or i < max) and v > cutoff
    }

    return d