Sort and remove duplicate