How can I read a text file, alphabatize it and then remove all duplicates down to 2

so

cow
cow
cow
fun
fun
me
me
me
me
we

NOW BECOMES

cow
cow
fun
fun
me
me
we

After that how can I read the same text file and be able to tell wich items are listed twice.

If anyone can tell me, this would be major help.