title: Sorting and Merging Using spark-shell
body: <p>I have a string array in scala</p>
  
  <pre><code>Array[String] = Array(apple, banana, oranges, grapes, lichi, anar)
  </code></pre>
  
  <p>I have converted it into a format like this:</p>
  
  <pre><code>Array[(Int, String)] = Array((5,apple), (6,banana), (7,oranges), (6,grapes), (5,lichi), (4,anar))
  </code></pre>
  
  <p>and i want output like this:</p>
  
  <pre><code>Array[(Int, String)] = Array((4,anar), (5,applelichi), (6,bananagrapes), (7,oranges))
  </code></pre>
  
  <p>means after sorting i want to add together the words with same key.
  i have done sorting. heres my code:</p>
  
  <pre><code>val a = sc.parallelize(List("apple","banana","oranges","grapes","lichi","anar"))
  val b = a.map(x =&gt;(x.length,x))
  val c = b.sortBy(_._2)
  </code></pre>