Here is what i am doing I am sorting and using the index instead of actually writing it as a value in array

my $hash; foreach my $csn (keys %$datastore) { push @{$hash->{$datastore->{$csn}->[3]}}, $datastore->{$csn}->[0]; } foreach (keys %$hash) { my @sorted = sort { $a <=> $b } @{$hash->{$_}}; $hash->{$_} = \@sorted; } foreach (keys %$datastore) { $datastore->{$_} = [$datastore->{$_}->[1],$datastore->{$_}->[2],$d +atastore->{$_}->[3], indexof($hash->{$datastore->{$_}->[3]}, $datasto +re->{$_}->[0])]; } sub indexof{ my ($array_ref, $search_for) = (shift, shift); my @array = @$array_ref; my( $index )= grep { $array[$_] eq $search_for } 0..$#array; return ($index + 1); }

Created an other hash with each unique d as key and value is a array ref with sorted a's and then use the index


In reply to Re^2: Hash of Array Sort question by sri1230
in thread Hash of Array Sort question by sri1230

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.