title: Sorting an Array of Hash by multiple keys Perl
body: <p>I have an array referance containing hashes (i.e. @AOH)</p>
  
  <pre><code>$arr_ref = [ { 'brand' =&gt; 'A',
                 'supplier' =&gt; 'X',
                 'PO' =&gt; '2'
                },
                { 'brand' =&gt; 'B',
                  'supplier' =&gt; 'Y',
                  'PO' =&gt; '1'       
                },
                { 'brand' =&gt; 'B',
                  'supplier' =&gt; 'X',
                  'PO' =&gt; '2'           
                },
                { 'brand' =&gt; 'A',
                  'supplier' =&gt; 'X',
                  'PO' =&gt; '1'
                },
                { 'brand' =&gt; 'B',
                  'supplier' =&gt; 'X',
                  'PO' =&gt; '1'           
                }
  ];
  </code></pre>
  
  <p>I want to sort it on the basis of all three keys (i.e. brand, supplier and PO).
  Order of sorting should be brand first, then supplier and then finally on PO.</p>
  
  <p>array referance after sorting should be:</p>
  
  <pre><code>$arr_ref = [ { 'brand' =&gt; 'A',
                  'supplier' =&gt; 'X',
                  'PO' =&gt; '1'
                },
                { 'brand' =&gt; 'A',
                 'supplier' =&gt; 'X',
                 'PO' =&gt; '2'
                },
                { 'brand' =&gt; 'B',
                  'supplier' =&gt; 'X',
                  'PO' =&gt; '1'           
                },
                { 'brand' =&gt; 'B',
                  'supplier' =&gt; 'X',
                  'PO' =&gt; '2'           
                },              
                { 'brand' =&gt; 'B',
                  'supplier' =&gt; 'Y',
                  'PO' =&gt; '1'       
                },
  ];
  </code></pre>