$i = -1; while (){ chomp; $i++; ($last[$i], $first[$i], $age[$i], $sex[$i], $height[$i], $weight[$i]) = split/,/; } die "Sorry, no data\n" if $i == -1; #### @alphabetical = sort @alphabetical # the above is equivalent to @alphabetical = sort {$a cmp $b} @alphabetical @numerical = sort {$a <=> $b} @numerical; # to reverse the sort order reverse the positions of $a and $b, or use reverse sort @a