malaga has asked for the wisdom of the Perl Monks concerning the following question:

i want this sorted by LastName, then FirstName when it prints. i don't know if this is set up all wrong for that. i think i would be sorting a hash, but where would i do it? inside the print tags, or before that?
my @row = split(/\t/); if ($row[11] ne undef) { my %data; @data{@fields} = @row; push @records, \%data; } } close (FILE); foreach my $ref ( @records ) { print "<a href = \"http://sph.berkeley.edu/cgi-bin/passtestfac.cgi +\?name\=$ref->{'ID'}\">", @{$ref}{qw/LastName/}, ',', ' ', @{$ref}{qw +/FirstName/}, "</a>", "<br>"; }
thanks.

Replies are listed 'Best First'.
Re: sort
by I0 (Priest) on Feb 08, 2001 at 06:31 UTC
    foreach my $ref ( sort {$a->{LastName} cmp $b->{LastName} or $a->{FirstName} cmp $b-> +{FirstName} } @records ){ print "<a href = \"http://sph.berkeley.edu/cgi-bin/passtestfac.cg +i\?name\=$ref->{'ID'}\">", @{$ref}{qw/LastName/}, ',', ' ', @{$ref}{q +w/FirstName/}, "</a>", "<br>"; }
Re: sort
by malaga (Pilgrim) on Feb 08, 2001 at 06:56 UTC
    you guys ARE MAGIC. thank you so much.