Sort by keys (ascending):

Sort by keys (descending):

Sort by values (ascending):

Sort by values (descending):

Credit: http://stackoverflow.com/questions/30787635/takeordered-descending-pyspark