<?xml version="1.0" encoding="windows-1252"?>
<node id="963190" title="sorting Array of hashes" created="2012-04-03 04:10:45" updated="2012-04-03 04:10:45">
<type id="115">
perlquestion</type>
<author id="963183">
balajinagaraju</author>
<data>
<field name="doctext">
&lt;p&gt;Hi Monks, 

I am newbie to perl and i am stuck at some point where i wanted to sort a datastructure as shown below , its basically an array of hashes and i am clueless how to sort it. I need testcase1, 2 and 3 and so on in an order and 
i need the 'step' to be listed from step1 to stepN in increasing order and i also need to sort the values within each step if the parameters are similar to what is listed under step4, i need them in order from param1 to param4.. Can anyone help me in solving this.&lt;/p&gt;
&lt;code&gt;my @array = (
    
      	'testcase1' =&gt; {
                         'step2' =&gt; {
                                    'command' =&gt; 'Goto'
                                  },
                         'step1' =&gt; {
                                    'param2' =&gt; 'dirpath',
                                    'param1' =&gt; 'executablepath',
                                    'command' =&gt; 'Launch '
                                  },
                         'step4' =&gt; {
                                    'param4' =&gt; '580',
                                    'param2' =&gt; '96',
                                    'param3' =&gt; '726',
                                    'param1' =&gt; '3',
                                    'command' =&gt; 'CaptureRectanlge'
                                  },
                         'step5' =&gt; {
                                    'image1' =&gt; 'D:\\\\img1.jpg',
                                    'image2' =&gt; 'D:\\\\img2.jpg ',
                                    'command' =&gt; 'CompareImage'
                                  },
                         'step3' =&gt; {
                                    'param1' =&gt; '100',
                                    'command' =&gt; 'Run'
                                  }
                       },
          'testcase2' =&gt; {
                         'step2' =&gt; {
                                    'command' =&gt; 'Goto'
                                  },
                         'step1' =&gt; {
                                    'param2' =&gt; 'dirpath',
                                    'param1' =&gt; 'executablepath',
                                    'command' =&gt; 'Launchsimulator '
                                  },
                         'step4' =&gt; {
                                    'param4' =&gt; '580',
                                    'param2' =&gt; '96',
                                    'param3' =&gt; '726',
                                    'param1' =&gt; '3',
                                    'command' =&gt; 'CaptureRectanlge'
                                  },
                         'step5' =&gt; {
                                    'image1' =&gt; 'D:\\\\img1.jpg',
                                    'image2' =&gt; 'D:\\\\img2.jpg ',
                                    'command' =&gt; 'CompareImage'
                                  },
                         'step3' =&gt; {
                                    'param1' =&gt; '100',
                                    'command' =&gt; 'Run'
                                  }
                       },
          'testcase3' =&gt; {
                        'command6' =&gt; 'F',
                        'commandA' =&gt; 'J',
                        'command8' =&gt; 'H',
                        'command7' =&gt; 'G',
                        'command9' =&gt; 'I'
                      }
&lt;/code&gt;

</field>
</data>
</node>
