Hello kfriman,

Is this something that you are looking for?

#!/usr/bin/perl use strict; use warnings; use Data::Dumper; my @AoA = ( [ "1", "PC BOX", "20.0" ], [ "1", "PC Spare", "32.0" ], [ "1", "PC Spare", "2.0" ], [ "1", "PC Spare", "5.2" ], [ "1", "PE Ak", "100.0" ], ); sub process_dublications { my $j = 0; my @AoA_local; my ($hashRefAoH) = @_; # print the whole thing with indices foreach my $key ( keys %{$hashRefAoH} ) { my $total; my $element = 0; foreach my $i ( 0 .. $#{ $hashRefAoH->{$key} } ) { $total += $hashRefAoH->{$key}[$i]; $element++; } push @{$AoA_local[$j++]}, $element, $key, $total; } return \@AoA_local; } my %HoA; # print the whole thing one at a time for my $i ( 0 .. $#AoA ) { next unless push @{ $HoA{$AoA[$i][1]} }, $AoA[$i][2]; } my $AoA_ref = process_dublications(\%HoA); my @sorted = sort { $a->[0] <=> $b->[0] || $a->[2] <=> $b->[2] } @{$Ao +A_ref}; print Dumper \@sorted; __END__ $VAR1 = [ [ 1, 'PC BOX', 20 ], [ 1, 'PE Ak', 100 ], [ 3, 'PC Spare', '39.2' ] ];

If you really want to keep the comma on the float you need to convert the comma to dot and after the calculation vise versa.

Hope this helps.

Seeking for Perl wisdom...on the process of learning...not there...yet!

In reply to Re: Grouping of 2D arrays by thanos1983
in thread Grouping of 2D arrays by kfriman

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.