title: How can i determine the maximum value in a list of tuples?
body: <p>my problem is a little bit complicated.. Actually as i asked before, i'm working with some biological data which are proteins. For each protein i have the <strong>name</strong> and it's <strong>annotation</strong>, for example:</p>
  <p><code>(B8DG74,2.7.8.7)</code></p>
  <p>Each protein have a list of neighbors, the groupByKey function in spark helped me to determine it, and they are separated by semicolon. So the list of neighbors looks like:</p>
  <p><code>(Q9LD43,2.1.3.15,1.0);(Q85X25,2.1.3.15,0.4);(Q6HCT2,2.1.3.15,0.7854127);(Q8Y6V8,2.1.3.15,0.14285715)</code></p>
  <p>As you can see, each neighbor is a tuple containing the neighbor name <code>Q9LD43</code> for example, its annotation <code>2.1.3.15</code> and another value which is the linkweight <code>1.0</code>.</p>
  <p>More clearly, the linkweight between <code>B8DG74</code> and <code>Q9LD43</code>  equals to <code>1.0</code>.</p>
  <p>How can I, based on this list of neighbors, determine the protein having the maximum link weight with our input protein?</p>
  <p>Here's my try:</p>
  <pre><code>s.map(l=&gt; {
        val (prot, annot) = l._1
        val listneighbors = l._2.toList //list of neighbors
  
        if (annot == &quot;null&quot;)
         {
           for ( i &lt;- listneighbors) { // the i is a tuple
           
             val neighbor_name = i._1
             val neighbor_annot = i._2
             val linkweight = i._3
             
             println(&quot;the max link weight between &quot; + prot + &quot; and its neighbors is &quot; + linkweight.max)}
  </code></pre>