def mark_metadata(metadata, subcollection, selposts):
    """
    Mark all posts corresponding to the current subcollection criteria.
    This is done in the form of a label in the subcollection column.
    """
    for post in selposts:
        postindex = metadata[metadata.filename == post].index[0]
        metadata.set_value(postindex, "subcollection", subcollection)
    metadata = metadata.sort_values(by="subcollection")
    return metadata