def apply_overwrites_to_context(context, overwrite_context):
    """Modify the given context in place based on the overwrite_context."""
    for variable, overwrite in overwrite_context.items():
        if variable not in context:
            continue
        context_value = context[variable]
        if isinstance(context_value, list):
            if overwrite in context_value:
                context_value.remove(overwrite)
                context_value.insert(0, overwrite)
        else:
            context[variable] = overwrite
