Removing duplicate lists from a list of lists

I’m trying to remove duplicate lists from a list of lists. (I’ve tried searching the forums but I have only found solutions for lists of strings, integers, etc. Those solutions don’t seem to work on a list of lists)

How would I remove duplicate items from a list such as the following:


set TheList to {{1, 2}, {3, 4}, {2, 2}, {1, 2}, {1, 1}, {3, 4}}
set TheList to RemoveDuplicates(TheList)
--> {{1, 2}, {3, 4}, {2, 2}, {1, 1}}


on RemoveDuplicates(TheList)

-- ??? what goes here ???

end RemoveDuplicates

A very good explanation of lists within lists comparisons is found here. Look for the How to compare lists that contain sublists topic.

Utilizing that information, try this script:


set TheList to {{1, 2}, {3, 4}, {2, 2}, {1, 2}, {1, 1}, {3, 4}}
set TheList to RemoveDuplicates(TheList)
-->{{1, 2}, {3, 4}, {2, 2}, {1, 1}}

to RemoveDuplicates(TheList)
	set newList to {}
	repeat with a from 1 to (TheList's length)
		if newList does not contain {(TheList's item a)} then set end of newList to (TheList's item a)
	end repeat
	return newList
end RemoveDuplicates

Thanks Craig

Your solution worked perfectly, and that link was very clear at explaining how lists of lists work.