I want to do the opposite thing as here

I have a list and I know how to remove the duplicates. But I want to have an option where the user can select which duplicate to keep. Some query quere I can have a list that will only show the duplicates. Something like:

Lets say my list is:

"tom" "bob" "Frank" "bob" "Lacey" "Frank"

I know that if I use the distinct method I will get:

"tom" "bob" "Frank" "Lacey"

I don't know what method to I have to use to get:

"bob" "bob" "frank" "frank"

or to get

"bob" "frank"

cause those are the ones that repeat.

Edit
Report