<SYSTEM_TASK:>
Given the following text problem statement, write Python code to implement the functionality described below in problem statement
<END_TASK>
<USER_TASK:>
Problem:
I get how to use pd.MultiIndex.from_tuples() in order to change something like
<ASSISTANT_TASK:>
Python Code:
import pandas as pd
import numpy as np
l = [('A', 'a', '1'), ('A', 'b', '2'), ('B','a', '1'), ('A', 'b', '1'),  ('B','b', '1'),  ('A', 'a', '2')]
np.random.seed(1)
df = pd.DataFrame(np.random.randn(5, 6), columns=l)
def g(df):
    df=df[sorted(df.columns.to_list())]
    df.columns = pd.MultiIndex.from_tuples(df.columns, names=['Caps','Middle','Lower'])
    return df
df = g(df.copy())
<END_TASK>