How to filter a list based on another list's values
<p>For example, I have two lists of the same length:</p>

<pre><code>a = [[1,2],[2,2],[3,3],[4,2],[5,6]]
b = [1,2,2,3,1]
</code></pre>

<p>I want to have a function such that </p>

<pre><code>func(a,b,1) = [[1,2],[5,6]]
func(a,b,2) = [[2,2],[3,3]]
func(b,b,2) = [2,2]
</code></pre>

<p>What the function does is return a list of a's elements, whose corresponding elements of the same index in list b equal to the third argument.</p>

<p>In Matlab I will do something as easy as a(b==1), a(b==2), b(b==2). What is the most efficient way to achieve this in Python?</p>
