Doing initial sort on lines of input