title: PHP - sort array by month and year
body: <p>This is my array:</p>
  
  <pre><code>$ar = array( 
   'Jan-2016' =&gt; 1,
   'Feb-2016' =&gt; 2,
   'Mar-2016' =&gt; 3,  
   'Apr-2016' =&gt; 4,
   'May-2016' =&gt; 4,
   'Jun-2016' =&gt; 4,
   'Jul-2016' =&gt; 4,
   'Aug-2016' =&gt; 4,
   'Sep-2016' =&gt; 4,
   'Oct-2016' =&gt; 4,
   'Nov-2016' =&gt; 4,
   'Dec-2016' =&gt; 4,
   'Jan-2015' =&gt; 1,
   'Mar-2015' =&gt; 1);
  </code></pre>
  
  <p>I want to sort this array by month &amp; year. I've tried below code:</p>
  
  <pre><code>ksort($ar);
  </code></pre>
  
  <p>But i can't get result as i expected.</p>
  
  <p>I need result as below array:</p>
  
  <pre><code>$ar = array(
   'Jan-2015' =&gt; 1,
   'Mar-2015' =&gt; 1,
   'Jan-2016' =&gt; 1,
   'Feb-2016' =&gt; 2,
   'Mar-2016' =&gt; 3,  
   'Apr-2016' =&gt; 4,
   'May-2016' =&gt; 4,
   'Jun-2016' =&gt; 4,
   'Jul-2016' =&gt; 4,
   'Aug-2016' =&gt; 4,
   'Sep-2016' =&gt; 4,
   'Oct-2016' =&gt; 4,
   'Nov-2016' =&gt; 4,
   'Dec-2016' =&gt; 4);
  </code></pre>