in reply to Sorting issues
#!/usr/bin/perl use strict; use warnings; my @urls = qw {yahoo.com ebay.com google.com}; my @links = qw {yahoo ebay google}; my @s_ind = sort {$urls [$a] cmp $urls [$b]} 0 .. $#urls; @urls = @urls [@s_ind]; @links = @links [@s_ind]; print "@urls\n"; print "@links\n"; __END__ ebay.com google.com yahoo.com ebay google yahoo
The code constructs an array with indices. First index is the position of the url that should come first, second index is the position of the url that should come second, etc, etc. Given that, sorting the urls and links happen in the same way.
Abigail
|
|---|