my @urls= qw( yahoo.com ebay.com google.com ); my @links= qw( yahoo ebay google ); my @idx= sort { $urls[$a] cmp $urls[$b] } 0..$#urls; # Now @urls[@idx] is sorted # and @links[@idx] is in the same order. # You could loop in that order like so: for my $i ( @idx ) { print "$urls[$i]\t$links[$i]\n"; } # Or you could just sort the arrays in place: @urls= @urls[@idx]; @links= @links[@idx];