Hi,

I need help in sorting of array. My array is like this.

@array = ( { level => 1, department = 'Office of President', }, { level => 2, department = 'Recruiting', }, { level => 2, department = 'Software', }, { level => 3, department = 'MIS', }, { level => 3, department = 'System Operations', }, { level => 2, department = 'Pipe line', }, );
basically this is made for tree like structure, when i print this array , it prints like this :
Office of the President Recruiting Software MIS System Operations PipeLine
Currently the department is not sorted alphabetically beacuse my array is created on the basis of level and it is in sequence. Now i want to sort the department alphabetically. How will i do this. I want this array print like this :
Office of the President (Make this as base level) PipeLine Recruiting Software MIS System Operations etc.....
Thanks

update (broquaint): added <code> tags


In reply to Logic for sorting of this given array by ravish

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.