sorting and removing duplicacy using HashSet