Get unique entries in list of lists by an item
<p>This seems like a fairly straightforward problem but I can't seem to find an efficient way to do it. I have a list of lists like this:</p>

<pre><code>list = [['abc','def','123'],['abc','xyz','123'],['ghi','jqk','456']]
</code></pre>

<p>I want to get a list of unique entries by the third item in each child list (the 'id'), i.e. the end result should be</p>

<pre><code>unique_entries = [['abc','def','123'],['ghi','jqk','456']]
</code></pre>

<p>What is the most efficient way to do this? I know I can use set to get the unique ids, and then loop through the whole list again. However, there are more than 2 million entries in my list and this is taking too long. Appreciate any pointers you can offer! Thanks. </p>

<p>One approach would be to create an inner loop. within the first loop you iterate over the outer list starting from 1, previously you will need to create an arraylist which will add the first element, inside the inner loop starting from index 0 you will check only if the third element is located as part of the third element within the arraylist current holding elements, if it is not found then on another arraylist whose scope is outside outher loop you will add this element, else you will use "continue" keyword.  Finally you will print out the last arraylist created.</p>

python list set