<h4 dir="auto">Problem description</h4>
<p dir="auto">I would like to subset the data frame with a indexer.  When using MultiIndex, the results are not following requested order.</p>
<h4 dir="auto">Code Sample, a copy-pastable example if possible</h4>
<p dir="auto">This works as expected when index is a simple <code class="notranslate">Index</code>: the returned entries are ordered as requested:</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="df = pd.DataFrame(
    {&quot;i1&quot;:[1,1,1,1,2,4,4,2,3,3,3,3],
     &quot;i2&quot;:[1,3,2,2,1,1,2,2,1,1,3,2],
     &quot;d1&quot;:['a','b','c','d','e','f','g','h','i','j','k','l']}
)
df.set_index(['d1',], inplace=True)
df.loc[[&quot;a&quot;,&quot;c&quot;,&quot;b&quot;],:]"><pre class="notranslate"><span class="pl-s1">df</span> <span class="pl-c1">=</span> <span class="pl-s1">pd</span>.<span class="pl-v">DataFrame</span>(
    {<span class="pl-s">"i1"</span>:[<span class="pl-c1">1</span>,<span class="pl-c1">1</span>,<span class="pl-c1">1</span>,<span class="pl-c1">1</span>,<span class="pl-c1">2</span>,<span class="pl-c1">4</span>,<span class="pl-c1">4</span>,<span class="pl-c1">2</span>,<span class="pl-c1">3</span>,<span class="pl-c1">3</span>,<span class="pl-c1">3</span>,<span class="pl-c1">3</span>],
     <span class="pl-s">"i2"</span>:[<span class="pl-c1">1</span>,<span class="pl-c1">3</span>,<span class="pl-c1">2</span>,<span class="pl-c1">2</span>,<span class="pl-c1">1</span>,<span class="pl-c1">1</span>,<span class="pl-c1">2</span>,<span class="pl-c1">2</span>,<span class="pl-c1">1</span>,<span class="pl-c1">1</span>,<span class="pl-c1">3</span>,<span class="pl-c1">2</span>],
     <span class="pl-s">"d1"</span>:[<span class="pl-s">'a'</span>,<span class="pl-s">'b'</span>,<span class="pl-s">'c'</span>,<span class="pl-s">'d'</span>,<span class="pl-s">'e'</span>,<span class="pl-s">'f'</span>,<span class="pl-s">'g'</span>,<span class="pl-s">'h'</span>,<span class="pl-s">'i'</span>,<span class="pl-s">'j'</span>,<span class="pl-s">'k'</span>,<span class="pl-s">'l'</span>]}
)
<span class="pl-s1">df</span>.<span class="pl-en">set_index</span>([<span class="pl-s">'d1'</span>,], <span class="pl-s1">inplace</span><span class="pl-c1">=</span><span class="pl-c1">True</span>)
<span class="pl-s1">df</span>.<span class="pl-s1">loc</span>[[<span class="pl-s">"a"</span>,<span class="pl-s">"c"</span>,<span class="pl-s">"b"</span>],:]</pre></div>
<p dir="auto">returns</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="#     i1  i2
# d1        
# a    1   1
# c    1   2 &lt;-- 'c' precedes 'b' as requested in query
# b    1   3
"><pre class="notranslate"><code class="notranslate">#     i1  i2
# d1        
# a    1   1
# c    1   2 &lt;-- 'c' precedes 'b' as requested in query
# b    1   3

</code></pre></div>
<p dir="auto">However, when querying a data frame with a <code class="notranslate">MultiIndex</code> the behaviour is inconsistent:</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="df = pd.DataFrame(
    {&quot;i1&quot;:[1,1,1,1,2,4,4,2,3,3,3,3],
     &quot;i2&quot;:[1,3,2,2,1,1,2,2,1,1,3,2],
     &quot;d1&quot;:['a','b','c','d','e','f','g','h','i','j','k','l']}
)
df.set_index(['d1',&quot;i1&quot;], inplace=True)
df.loc[[&quot;a&quot;,&quot;c&quot;,&quot;b&quot;],:]"><pre class="notranslate"><span class="pl-s1">df</span> <span class="pl-c1">=</span> <span class="pl-s1">pd</span>.<span class="pl-v">DataFrame</span>(
    {<span class="pl-s">"i1"</span>:[<span class="pl-c1">1</span>,<span class="pl-c1">1</span>,<span class="pl-c1">1</span>,<span class="pl-c1">1</span>,<span class="pl-c1">2</span>,<span class="pl-c1">4</span>,<span class="pl-c1">4</span>,<span class="pl-c1">2</span>,<span class="pl-c1">3</span>,<span class="pl-c1">3</span>,<span class="pl-c1">3</span>,<span class="pl-c1">3</span>],
     <span class="pl-s">"i2"</span>:[<span class="pl-c1">1</span>,<span class="pl-c1">3</span>,<span class="pl-c1">2</span>,<span class="pl-c1">2</span>,<span class="pl-c1">1</span>,<span class="pl-c1">1</span>,<span class="pl-c1">2</span>,<span class="pl-c1">2</span>,<span class="pl-c1">1</span>,<span class="pl-c1">1</span>,<span class="pl-c1">3</span>,<span class="pl-c1">2</span>],
     <span class="pl-s">"d1"</span>:[<span class="pl-s">'a'</span>,<span class="pl-s">'b'</span>,<span class="pl-s">'c'</span>,<span class="pl-s">'d'</span>,<span class="pl-s">'e'</span>,<span class="pl-s">'f'</span>,<span class="pl-s">'g'</span>,<span class="pl-s">'h'</span>,<span class="pl-s">'i'</span>,<span class="pl-s">'j'</span>,<span class="pl-s">'k'</span>,<span class="pl-s">'l'</span>]}
)
<span class="pl-s1">df</span>.<span class="pl-en">set_index</span>([<span class="pl-s">'d1'</span>,<span class="pl-s">"i1"</span>], <span class="pl-s1">inplace</span><span class="pl-c1">=</span><span class="pl-c1">True</span>)
<span class="pl-s1">df</span>.<span class="pl-s1">loc</span>[[<span class="pl-s">"a"</span>,<span class="pl-s">"c"</span>,<span class="pl-s">"b"</span>],:]</pre></div>
<p dir="auto">returns</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="#        i2
# d1 i1    
# a  1    1
# b  1    3 
# c  1    2  &lt;-- 'c' follows 'b' unlike in query"><pre class="notranslate"><code class="notranslate">#        i2
# d1 i1    
# a  1    1
# b  1    3 
# c  1    2  &lt;-- 'c' follows 'b' unlike in query
</code></pre></div>
<h4 dir="auto">Expected Output</h4>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="#        i2
# d1 i1    
# a  1    1
# c  1    2
# b  1    3 "><pre class="notranslate"><code class="notranslate">#        i2
# d1 i1    
# a  1    1
# c  1    2
# b  1    3 
</code></pre></div>
<h4 dir="auto">Output of <code class="notranslate">pd.show_versions()</code></h4>
<details>
INSTALLED VERSIONS
------------------
commit: None
python: 3.5.1.final.0
python-bits: 64
OS: Darwin
OS-release: 14.5.0
machine: x86_64
processor: i386
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8
<p dir="auto">pandas: 0.19.2<br>
nose: 1.3.7<br>
pip: 9.0.1<br>
setuptools: 34.4.1<br>
Cython: 0.24<br>
numpy: 1.12.1<br>
scipy: 0.19.0<br>
statsmodels: 0.6.1<br>
xarray: None<br>
IPython: 5.3.0<br>
sphinx: 1.4.5<br>
patsy: 0.4.1<br>
dateutil: 2.6.0<br>
pytz: 2017.2<br>
blosc: None<br>
bottleneck: None<br>
tables: 3.2.2<br>
numexpr: 2.6.0<br>
matplotlib: 2.0.0<br>
openpyxl: None<br>
xlrd: None<br>
xlwt: None<br>
xlsxwriter: None<br>
lxml: None<br>
bs4: 4.5.3<br>
html5lib: 0.999999999<br>
httplib2: 0.9.2<br>
apiclient: 1.5.1<br>
sqlalchemy: 1.0.14<br>
pymysql: None<br>
psycopg2: None<br>
jinja2: 2.9.6<br>
boto: 2.42.0<br>
pandas_datareader: None</p>
</details>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="In [40]: cols = pd.MultiIndex.from_product([['A', 'B', 'C'],[1,2]])

In [41]: df = pd.DataFrame(np.random.randn(5,6), columns=cols)

In [42]: df.loc[:, ['B', 'A']]
Out[42]:
          A                   B
          1         2         1         2
0 -0.990868  1.577803  1.023247 -0.423165
1 -1.180170  1.236143 -1.484085  0.044929
2  1.665502 -0.711081  0.227827  0.651859
3 -0.659154  0.154327 -1.548650 -0.070550
4 -0.232819  0.100959 -0.102296  0.260816"><pre class="notranslate"><code class="notranslate">In [40]: cols = pd.MultiIndex.from_product([['A', 'B', 'C'],[1,2]])

In [41]: df = pd.DataFrame(np.random.randn(5,6), columns=cols)

In [42]: df.loc[:, ['B', 'A']]
Out[42]:
          A                   B
          1         2         1         2
0 -0.990868  1.577803  1.023247 -0.423165
1 -1.180170  1.236143 -1.484085  0.044929
2  1.665502 -0.711081  0.227827  0.651859
3 -0.659154  0.154327 -1.548650 -0.070550
4 -0.232819  0.100959 -0.102296  0.260816
</code></pre></div>