Duplicate documents

Hi
I have a doc list which has a set of documnets in which some are duplicate.how can i get a doclist of distinct documents from this doclist?
The duplicate docs have all the elements same…
problem doclist resultant doclist
should look like this
eg:- doclist
doc[0]
str1-a
str2-1
doc[1]
str1-b
str2-2
doc[2]
str1-a
str2-1

resultant doclist should look like this

doclist
doc[0]
str1-a
str2-1
doc[1]
str1-b
str2-2

You can write a service to go over these docs and create a doc list of distinct docs, but it wouldn’t be very efficient; I suggest looking into the process that populated this doc list e.g., if its from some rdbms try optimizing the query by adding distinct keyword in select sql etc.,

Hello,
Get the length of the list. Build a service that can do a recursive call, passing the whole list and the starting index. In this call, pull out the document to represent that position index. loop compare to all elements whose index is higher than yours. If you find a match, do nothing. If you do not find a match, append to a return list. Then do another recursive call passing the new higher index and the same doc list. You keep going until index >= length and then return the list. At the end the top most call will have a list whose elements are distinct and the oldest copies (lower index) will have been removed. I leave how you compare the elements up to you as this can work with many types. Good day.

Yemi Bedu.