def find_pop(db, k, spec_range):
    """
    :param db: list of designs
    :param k: integer indicating the cut off rank
    :param spec_range: dictionary indicating the desired specifications
    :return:
    pop: dictionary: keywords are the desired specs as well as 'cost'.values are db entries
    sorted by the keyword criteria
    """
    assert k <= len(db), "k={} is not less that len(db)={}".format(k, len(db))
    pop = {}
    pop['cost'] = sorted(db, key=lambda x: x.cost)[:k]
    for kwrd in spec_range.keys():
        spec_min, spec_max, _ = spec_range[kwrd]
        reverse = True if spec_min is not None else False
        pop[kwrd] = sorted(db, key=lambda x: x.specs[kwrd], reverse=reverse)[:k]

    return pop