Compare lists of records

I have two lists of records with this structure:

{pdfName:ThisPDFname, DOIofPDF:myDOI}

Which is the fasted way to compare them? I want to remove same records which are present in both lists.

Thanks

So you common items removed from both lists?

yes. For example:
LIST1
{pdfName:A.pdf, DOIofPDF:1}
{pdfName:B.pdf, DOIofPDF:2}
{pdfName:C.pdf, DOIofPDF:3}

List1
{pdfName:A.pdf, DOIofPDF:1}
{pdfName:B.pdf, DOIofPDF:3}
{pdfName:D.pdf, DOIofPDF:4}

Only
{pdfName:A.pdf, DOIofPDF:1}
should be removed from both lists.

You could use this:

set list1 to {{pdfName:"A.pdf", DOIofPDF:1}, {pdfName:"B.pdf", DOIofPDF:2}, {pdfName:"C.pdf", DOIofPDF:3}}
set list2 to {{pdfName:"A.pdf", DOIofPDF:1}, {pdfName:"B.pdf", DOIofPDF:3}, {pdfName:"D.pdf", DOIofPDF:4}}
set list1New to {}
set list2New to {}
repeat with anItem in list1
	set anItem to contents of anItem
	if list2 does not contain {anItem} then set end of list1New to anItem
end repeat
repeat with anItem in list2
	set anItem to contents of anItem
	if list1 does not contain {anItem} then set end of list2New to anItem
end repeat
return {list1New, list2New}

For very long lists, this might be quicker:

use framework "Foundation"
use scripting additions

set list1 to {{pdfName:"A.pdf", DOIofPDF:1}, {pdfName:"B.pdf", DOIofPDF:2}, {pdfName:"C.pdf", DOIofPDF:3}}
set list2 to {{pdfName:"A.pdf", DOIofPDF:1}, {pdfName:"B.pdf", DOIofPDF:3}, {pdfName:"D.pdf", DOIofPDF:4}}
set list1 to current application's NSMutableArray's arrayWithArray:list1
set list1Copy to list1's |copy|()
set list2 to current application's NSMutableArray's arrayWithArray:list2
list1's removeObjectsInArray:list2
list2's removeObjectsInArray:list1Copy
return {list1 as list, list2 as list}

This was my error. I didn’t “set anItem to contents of anItem”. I just used directly “anItem”

And this will be useful since my list is more that 1000 records.
Thanks a lot !!!