Hello List,

I have a data structure containing a bunch of strings in different groups:

$groups = [
            [
              'SSPDQR',
              'SSPSDR',
              'STSSER',
            ],
            [
              'CSANLH',
              'CVANRD',
            ],
            [...],
            ...,
          ];
etc.

I want these sorted first alphabetically within the group, and then according to the number of member in the group.

I have this code and it works fine:

my @s_groups = ();
for my $i (0 .. $#$groups) {
    my @temp = sort { $a cmp $b } @{ $groups->[$i] };
    push @s_groups, [EMAIL PROTECTED];
}

@s_groups = sort { @$b <=> @$a } @s_groups;

However, I have a feeling that this can be optimized due to its awkward appearance. Does anyone have any ideas as to how to tighten up this code? I'm trying to think of a way to incorporate a Schwartzian Transform, but am unsure how to do so on this particular data structure.

This is not a critical question since the code works, but I'd appreciate input all the same.

Thanks in advance for any help.

Sincerely,
Adam

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to