Line completion: sort and uniquify lines