sort data to keep lines the same color.