Removing duplicates and sorting.