Fix sorting of lines