title: sort array on clothing sizes (multidimensional array)
body: <p>My array looks like this:</p>
  
  <pre><code>    Array
       (
       [0] =&gt; Array
      (
          [id] =&gt; 613
          [kleur] =&gt; royalblauw/wit
          [maat] =&gt;  maat XL
          [voorraad] =&gt; 100
          [sort] =&gt; 0
          [prijs] =&gt; 4.1320
      )
  
  [1] =&gt; Array
      (
          [id] =&gt; 614
          [kleur] =&gt; royalblauw/wit
          [maat] =&gt;  maat XXL
          [voorraad] =&gt; 100
          [sort] =&gt; 1
          [prijs] =&gt; 4.1320
      )
  
  [2] =&gt; Array
      (
          [id] =&gt; 620
          [kleur] =&gt; zwart/wit
          [maat] =&gt;  maat XL
          [voorraad] =&gt; 100
          [sort] =&gt; 2
          [prijs] =&gt; 4.1320
      ) 
         etc.etc.
  </code></pre>
  
  <p>What I want is to sort the array by 'maat' (size). As you can see there are multiple entries with same 'maat'. </p>
  
  <p>I've been trying for hours now, but still not a good result. Ofcourse I've been looking at Stackoverflow, too. This is what I have until now. </p>
  
  <p>Functions:</p>
  
  <pre><code>function cmp($a, $b)
  {
  
  $sizes = array(
  "116" =&gt; 0,
  "128" =&gt; 1,
  "140" =&gt; 2,
  "152" =&gt; 3,
  "164" =&gt; 4,
  "XXS" =&gt; 5,
  "XS" =&gt; 6,
  "S" =&gt; 7,
  "M" =&gt; 8,
  "L" =&gt; 9,
  "XL" =&gt; 10,
  "XXL" =&gt; 11,
  "XXXL" =&gt; 12,
  "XXXXL" =&gt; 13,
  "XXXXXL" =&gt; 14
  );
  
  $asize = $sizes[$a];
  $bsize = $sizes[$b];
  
  if ($asize == $bsize) {
      return 0;
  }
  
  return ($asize &gt; $bsize) ? 1 : -1;
  
  }
  function aasort (&amp;$array, $key) {
      $sorter=array();
      $ret=array();
      reset($array);
      foreach ($array as $ii =&gt; $va) {
          $sorter[$ii]=$va[$key];
      }
      uasort($sorter, "cmp");
      foreach ($sorter as $ii =&gt; $va) {
          $ret[$ii]=$array[$ii];
      }
      $array=$ret;
  }
  </code></pre>
  
  <p>And calling the function aasort:</p>
  
  <pre><code>aasort($maatkleur_array,"maat");
  </code></pre>
  
  <p>Please can you help me. I hope it's clear what I want to achieve.</p>