in reply to sorting arrays with common index

Think about how you would do this in a spreadsheet.
You would make columns for the values of HOST_IP, HOST_NAME, and HOST_DESCRIPTION.
Then you would select the area of the spreadsheet, then use the sort tool to sort by Column B.
Do it the same way in Perl.

Make a single structure that is what we call an Array of Arrays, what you may think of as a 2-d Matrix. Then just sort it by "Column B", e.g. 2 or index 1 in this case. Perl numbers arrays starting at zero.

Here is some code that may move you in the right direction:

#!/usr/bin/perl use strict; use warnings; use Data::Dumper; my @HOST_IP = ("1.2.3", "5.6.7", "8.9.10"); my @HOST_NAME = ("Mary", "Zeke", "Bob"); my @HOST_DESCRIPTION = ("Development", "Test", "Manufacturing"); # create a single array structure and then sort that my @AoA; while (@HOST_IP) { push @AoA, [shift @HOST_IP, shift @HOST_NAME, shift @HOST_DESCRIPTION]; } print "The combined data as an Array of Array:\n"; foreach my $arrayRef (@AoA) { print "@$arrayRef\n"; } @AoA = sort {$a->[1] cmp $b->[1]} @AoA; print "\nSorted by column 2...\n"; foreach my $arrayRef (@AoA) { print "@$arrayRef\n"; } __END__ Prints: The combined data as an Array of Array: 1.2.3 Mary Development 5.6.7 Zeke Test 8.9.10 Bob Manufacturing Sorted by column 2... 8.9.10 Bob Manufacturing 1.2.3 Mary Development 5.6.7 Zeke Test