You need the Schwartzian Transform. If you do a search or super search on sorting you will find an abundance of nodes. You could also look up the the Orcish Manouver (a pun on or cache). There is also a great paper on sorting A Fresh Look at Efficient Perl Sorting

Update

As merlyn points out below you do not need Schwartzian/Orcish as your sort keys are already there. If you have a large amount of data to sort you may get some efficiency gain from the "Packed Default" method in the Guttman & Rosler paper A Fresh Look at Efficient Perl Sorting Here is an example of the Packed Default method ...
%hash=( 1 => [ 51, 'a2'], 2 => [42, 'a1'] ); print "$_ => @{$hash{$_}}" for map substr($_,2), sort map {pack("C2", $hash{$_}[0])."$_"} keys %hash;
but for simplicity go for one of the solutions below.

Cheers,
R.

Pereant, qui ante nos nostra dixerunt!

In reply to Re: Sorting a hash of arrays based on a particular array element. by Random_Walk
in thread Sorting a hash of arrays based on a particular array element. by aditya.singh

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.