 <p>You could construct <code>sqlite</code> database tables and query them for the results you want.</p> <pre><code>import sqlite3, operator reference = [[1, 0, 0], [2, 0, 10], [3, 0, 20], [4, 0, 30], [5, 0, 40]] temperature = [[0, 0, 100], [0, 10, 110], [0, 20, 120], [0, 30, 130], [0, 40, 140]] </code></pre> <p>A couple of helpers - I like using these because it makes subsequent code readable.</p> <pre><code>reference_coord = operator.itemgetter(1,2) ref = operator.itemgetter(0) temperature_coord = operator.itemgetter(0,1) temp = operator.itemgetter(2) </code></pre> <p>Create a database (in memory)</p> <pre><code>con = sqlite3.connect(":memory:") </code></pre> <p>Two ways to approach this, preserve all the information in separate tables or create a single table with only the data you want</p> <hr> <p>One table for each list</p> <pre><code>con.execute("create table reference(coordinate TEXT PRIMARY KEY, reference INTEGER)") con.execute("create table temperature(coordinate TEXT PRIMARY KEY, temperature INTEGER)") # fill the tables parameters = [(str(reference_coord(item)), ref(item)) for item in reference] con.executemany("INSERT INTO reference(coordinate, reference) VALUES (?, ?)", parameters) parameters = [(str(temperature_coord(item)), temp(item)) for item in temperature] con.executemany("INSERT INTO temperature(coordinate, temperature) VALUES (?, ?)", parameters ) </code></pre> <p>Query the two tables for the data you need</p> <pre><code>cursor = con.execute('SELECT reference.reference, temperature.temperature FROM reference, temperature WHERE reference.coordinate = temperature.coordinate') print(cursor.fetchall()) </code></pre> <hr> <p>Table that combines the data in the two lists</p> <pre><code>con.execute("create table data(coordinate TEXT PRIMARY KEY, reference INTEGER, temperature INTEGER)") </code></pre> <p>Build the table with only the data you care about</p> <pre><code>parameters = [(str(reference_coord(item)), ref(item)) for item in reference] con.executemany("INSERT INTO data(coordinate, reference) VALUES (?, ?)", parameters) parameters = [(temp(item), str(temperature_coord(item))) for item in temperature] con.executemany("UPDATE data SET temperature=? WHERE coordinate=?", parameters) </code></pre> <p>Simple query because the table only has what you want</p> <pre><code>cursor2 = con.execute('SELECT reference, temperature FROM data') print(cursor2.fetchall()) con.close() </code></pre> <p>Result:</p> <pre><code>&gt;&gt;&gt; [(1, 100), (2, 110), (3, 120), (4, 130), (5, 140)] [(1, 100), (2, 110), (3, 120), (4, 130), (5, 140)] &gt;&gt;&gt; </code></pre> <p>Once you get your data into a database it is fairly easy to extract information from it, and the database can be persisted if a file db is used instead of a db in memory.</p> <p>If an external library is acceptable, <a href="http://pandas.pydata.org" rel="nofollow">pandas</a> has similar functionality and is an awesome package.</p>