title: spark - compare key with values
body: <p>i'm starting with spark, and i didn't understand some concepts yet.</p>
  
  <p>I have a file with pairs of names like this:</p>
  
  <pre><code>foo bar
  bar foo
  </code></pre>
  
  <p>But are the same relation between foo and bar. i'm trying to create a rdd with just one relation</p>
  
  <pre><code>foo bar
  </code></pre>
  
  <p>I create this code:</p>
  
  <pre><code>step1 = joined.reduceByKey(lambda x,y: x+';'+y).map(lambda x: (x[0], x[1].split(';'))).sortByKey(True).mapValues(lambda x: sorted(x)).collect()
  </code></pre>
  
  <p>to create the first output, and i think i need another reduceByKey to remove existing values for the previous iteration but i don't know how to do that. </p>
  
  <p>Am I thinking correctly?</p>