<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question Spark sort by key with descending order in Archives of Support Questions (Read Only)</title>
    <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Spark-sort-by-key-with-descending-order/m-p/224232#M69931</link>
    <description>&lt;P&gt;rdd.sortByKey() sorts in ascending order.&lt;/P&gt;&lt;P&gt;I want to sort in descending order.&lt;/P&gt;&lt;P&gt;I tried rdd.sortByKey("desc") but it did not work&lt;/P&gt;</description>
    <pubDate>Thu, 19 Oct 2017 10:15:53 GMT</pubDate>
    <dc:creator>sreeviswa_athic</dc:creator>
    <dc:date>2017-10-19T10:15:53Z</dc:date>
    <item>
      <title>Spark sort by key with descending order</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Spark-sort-by-key-with-descending-order/m-p/224232#M69931</link>
      <description>&lt;P&gt;rdd.sortByKey() sorts in ascending order.&lt;/P&gt;&lt;P&gt;I want to sort in descending order.&lt;/P&gt;&lt;P&gt;I tried rdd.sortByKey("desc") but it did not work&lt;/P&gt;</description>
      <pubDate>Thu, 19 Oct 2017 10:15:53 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Spark-sort-by-key-with-descending-order/m-p/224232#M69931</guid>
      <dc:creator>sreeviswa_athic</dc:creator>
      <dc:date>2017-10-19T10:15:53Z</dc:date>
    </item>
    <item>
      <title>Re: Spark sort by key with descending order</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Spark-sort-by-key-with-descending-order/m-p/224233#M69932</link>
      <description>&lt;P&gt;Try using rdd.sortByKey(false)&lt;/P&gt;&lt;P&gt;This will sort in descending order&lt;/P&gt;</description>
      <pubDate>Thu, 19 Oct 2017 10:17:36 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Spark-sort-by-key-with-descending-order/m-p/224233#M69932</guid>
      <dc:creator>dineshc</dc:creator>
      <dc:date>2017-10-19T10:17:36Z</dc:date>
    </item>
    <item>
      <title>Re: Spark sort by key with descending order</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Spark-sort-by-key-with-descending-order/m-p/224234#M69933</link>
      <description>&lt;P&gt;Try this code&lt;/P&gt;&lt;PRE&gt;from pyspark import SparkConf, SparkContext
from pyspark.sql import SQLContext
conf1 = SparkConf().setAppName('sort_desc')
sc1 = SparkContext(conf=conf1)
sql_context = SQLContext(sc1)
csv_file_path = 'emp.csv'
employee_rdd = sc1.textFile(csv_file_path).map(lambda line: line.split(','))
print(type(employee_rdd))
employee_rdd_sorted = employee_rdd.sortByKey(ascending= False)
employee_df = employee_rdd.toDF(['dept','ctc'])
employee_df_sorted = employee_rdd_sorted.toDF(['dept','ctc'])&lt;/PRE&gt;</description>
      <pubDate>Fri, 20 Oct 2017 13:34:20 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Spark-sort-by-key-with-descending-order/m-p/224234#M69933</guid>
      <dc:creator>thangarajanp</dc:creator>
      <dc:date>2017-10-20T13:34:20Z</dc:date>
    </item>
  </channel>
</rss>

