How do I sort RDD on two fields: first Desc and then second Asc



I have a RDD like: (String, Int)

How can I sort it on value field first and in desc order, and then sort it on key field?

Thank you very much.


To sort by key use sortByKey() API.
To sort the key in desc use sortBykey(false).
Then to sort the value use scala API sortBy() and give the value field in the tuple to sort.
Negate the value to sort it in desc