title: Compare current and all next value in records in map in spark
body: <p>I am new to scala. Sample data :</p>
  
  <pre><code>1,"jack",34.5
  2,"jackk",14.5
  3,"jacky",24.5
  4,"jack",64.5
  And many more.
  </code></pre>
  
  <p>I want to compare each filed of first record with all other field, then second with all other and so on. (Please don't consider Syntaxs)
  I have written below code :</p>
  
  <pre><code>    val data = sc.parallalize(Seq((1,"jack",34.5),
          (2,"jackk",14.5),
          (3,"jacky",24.5),
         (4,"jack",64.5))
  
     val res = data.map{f =&gt; 
            val rr = f._1.equals(f._1)   //here same field compare with each other But I want to compare current record with all next records.
            Row(rr)  
          }
  </code></pre>
  
  <p>Example:</p>
  
  <pre><code>"jack" with "jackk"
  "jack" with "jacky"
  "jack" with "jack"
  "jackk" with "jacky"
  "jackk" with "jack"
  "jacky" with "jack"
  </code></pre>
  
  <p>I am using <code>.map</code> because i want code should be executed on cluster.</p>
  
  <p>Please Give some suggestion.
  Thanks in Advance.</p>