how to delete duplicates portions of strings

I have a vector of vectors of strings. I modify the vector of vectors. Then I output the modified data. Each component has a name of whom it belongs to in the format lastname,firstname . I list it alphabetically. I want to remove duplicates of the names. say it would delete the first and last name if it has a , and is greater than length 3. How would I go about doing that?