sorting a list of tuples in Pyspark
<p>I have a set of tuple key,value pairs which look like this:</p>

<pre><code>X=[(('cat','mouse'),1),(('dog','rat'),20),(('hamster','skittles),67)]
</code></pre>

<p>which I want to sort in order of the second item in the tuple. Pythonically I would have used:</p>

<pre><code>sorted(X, key=lambda tup:tup[1])
</code></pre>

<p>I also want to get the key,value pair with the highest value, again, pythonically this would be simple:</p>

<pre><code>max_X=max(x[1] for x in X)
max_tuple=[x for x in X if x[1]==max_X
</code></pre>

<p>however I do not know how to translate this into a spark job.</p>