I have a RDD of `(key, (val1,val2))`. For this `rdd`, I would like to apply `reduceByKey` function and my requirement is to find minimum of `val2` against a single key and also extract the `val1` of the resulted minimum `val2`.
Eg: `(1,(a,4)),(2,(b,3)),(1,(c,2)),(2,(d,1))`
In this I wanted the result set as `(1,(c,2)),(2,(d,1))`

I have in my mind below python code, but here I am getting the first `val1`, not the `val1` corresponding to minimum `val2`.

```
rdd2 = rdd1.map(lambda x:(x[0],(x[1],x[3])))
rdd3 = rdd2.reduceByKey(lambda x,y:(x[0],min(x[1],y[1])))

```

Please help me to modify the code inorder to get my required result.