I have an array like
@new ("1.1.1.1 stlmo #Web Server",
"1.1.1.2 atlga #Web Server",
"1.1.1.3 houtx #"1.1.1.4 stlmo #FTP Server",
"1.1.1.5 stlga #FTP Server",
"1.1.1.6 houtx #FTP Server");
I am trying to sort by the comments first then on the hostname. The code I was trying was
but (as I'm sure you know cause I'm posting here) it isn't working as expected.
@new ("1.1.1.1 stlmo #Web Server",
"1.1.1.2 atlga #Web Server",
"1.1.1.3 houtx #"1.1.1.4 stlmo #FTP Server",
"1.1.1.5 stlga #FTP Server",
"1.1.1.6 houtx #FTP Server");
I am trying to sort by the comments first then on the hostname. The code I was trying was
Code:
@new = map { $_->[0] }
sort { $a->[3] cmp $b->[3] || $a->[2] cmp $b->[2]}
map { [$_, (split /s+/),$_,3] } @new;
for (@new) { print "$_\n"; }
but (as I'm sure you know cause I'm posting here) it isn't working as expected.