def align_with_static_component(n, c, attr):
    """
    Alignment of time-dependent variables with static components. If c is a
    pypsa.component name, it will sort the columns of the variable according
    to the statid component.
    """
    if c in n.all_components and (c, attr) in n.variables.index:
        if not n.variables.pnl[c, attr]:
            return
        if len(n.vars[c].pnl[attr].columns) != len(n.df(c).index):
            return
        n.vars[c].pnl[attr] = n.vars[c].pnl[attr].reindex(columns=n.df(c).index
            )
