human
Complete this python program:
def format_dictlist(dictlist, features):
assistant
#Here is the Python program you requested.

    """Convert a list of dictionaries to be compatible with create_csv_response
    `dictlist` is a list of dictionaries
    all dictionaries should have keys from features
    `features` is a list of features
    example code:
    dictlist = [
    \label1\: \value-1,1\,
    \label2\: \value-1,2\,
    \label3\: \value-1,3\,
    \label4\: \value-1,4\,
    \label1\: \value-2,1\,
    \label2\: \value-2,2\,
    \label3\: \value-2,3\,
    \label4\: \value-2,4\,
    header, datarows = format_dictlist(dictlist, [\label1\, \label4\])
    # results in
    header = [\label1\, \label4\]
    datarows = [[\value-1,1\, \value-1,4\],
    [\value-2,1\, \value-2,4\]]
    """
    def dict_to_entry(dct):
        '    Convert    dictionary    to    a    list    for    a    csv    row    '
        relevant_items = [(k, v) for (k, v) in dct.items() if (k in features)]
        ordered = sorted(relevant_items, key=(lambda (k, v): header.index(k)))
        vals = [v for (_, v) in ordered]
        return vals
    header = features
    datarows = map(dict_to_entry, dictlist)
    return (header, datarows)