Perl has an internal sort function that can even sort on arbitrary criteria.
"input.txt".slurp.sort.say will sort the rows of the line according to the ASCII table
"input.txt".slurp.sort:{ $^a <=> $^b }.say will sort the rows