open(FILE, "<", $filename) or die $!; foreach my $line (sort ) { print $line; } close FILE;