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.

my @array = ( 'testcase1' => { 'step2' => { 'command' => 'Goto' }, 'step1' => { 'param2' => 'dirpath', 'param1' => 'executablepath', 'command' => 'Launch ' }, 'step4' => { 'param4' => '580', 'param2' => '96', 'param3' => '726', 'param1' => '3', 'command' => 'CaptureRectanlge' }, 'step5' => { 'image1' => 'D:\\\\img1.jpg', 'image2' => 'D:\\\\img2.jpg ', 'command' => 'CompareImage' }, 'step3' => { 'param1' => '100', 'command' => 'Run' } }, 'testcase2' => { 'step2' => { 'command' => 'Goto' }, 'step1' => { 'param2' => 'dirpath', 'param1' => 'executablepath', 'command' => 'Launchsimulator ' }, 'step4' => { 'param4' => '580', 'param2' => '96', 'param3' => '726', 'param1' => '3', 'command' => 'CaptureRectanlge' }, 'step5' => { 'image1' => 'D:\\\\img1.jpg', 'image2' => 'D:\\\\img2.jpg ', 'command' => 'CompareImage' }, 'step3' => { 'param1' => '100', 'command' => 'Run' } }, 'testcase3' => { 'command6' => 'F', 'commandA' => 'J', 'command8' => 'H', 'command7' => 'G', 'command9' => 'I' }

In reply to sorting Array of hashes by balajinagaraju

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.