title: Cutomise the ordering of columns in pivot table after .sort_index(level=1, axis=1)
body: <p>Dataframe <code>df1</code></p>
  <pre><code>    TYPE  WEEK  A  B  C  D
  0  Type1     1  1  1  1  1
  1  Type2     2  2  2  2  2
  2  Type3     3  3  3  3  3
  3  Type4     4  4  4  4  4
  
  </code></pre>
  <p>Expected output</p>
  <pre><code>         A    C    B    D    A    C    B    D    A    C    B    D    A    C    B    D
  WEEK     1    1    1    1    2    2    2    2    3    3    3    3    4    4    4    4
  TYPE
  Type1  1.0  1.0  1.0  1.0  NaN  NaN  NaN  NaN  NaN  NaN  NaN  NaN  NaN  NaN  NaN  NaN
  Type2  NaN  NaN  NaN  NaN  2.0  2.0  2.0  2.0  NaN  NaN  NaN  NaN  NaN  NaN  NaN  NaN
  Type3  NaN  NaN  NaN  NaN  NaN  NaN  NaN  NaN  3.0  3.0  3.0  3.0  NaN  NaN  NaN  NaN
  Type4  NaN  NaN  NaN  NaN  NaN  NaN  NaN  NaN  NaN  NaN  NaN  NaN  4.0  4.0  4.0  4.0
  </code></pre>
  <p>My approach:</p>
  <pre><code>df1 = pd.DataFrame(df1)
  
  colname = list(df1.head())
  tuples = []
  
  for i in colname:
      tuples.append((i,colname.index(i)+1))
      
  index = pd.MultiIndex.from_tuples(tuples, names=[&quot;COLUMN&quot;, &quot;ORDER&quot;])   
  df2 = pd.DataFrame(df1.values, columns=index)
  
  df3 = pd.pivot_table(df1,index=&quot;TYPE&quot;,columns=&quot;WEEK&quot;, values=['A','B','C','D']).sort_index(level=1, axis=1)
  #For df3 cannot attain the expected result because .sort_index(level=1, axis=1) will sort them out alphabetically to ['A','B','C','D']
  </code></pre>
  <p><code>.sort_index(level=1, axis=1)</code> is required to swap the level of the pivot table.</p>
  <p>Another dataframe <code>df2</code> is generated in order to fix the order of columns as <code>['A','C','B','D']</code> to be used in the pivot table</p>
  <pre><code>COLUMN   TYPE WEEK  A  B  C  D
  ORDER       1    2  3  4  5  6
  0       Type1    1  1  1  1  1
  1       Type2    2  2  2  2  2
  2       Type3    3  3  3  3  3
  3       Type4    4  4  4  4  4
  </code></pre>