sort and remove comments