Databricks Certified Associate Developer for Apache Spark — Question 57
Which of the following code blocks fails to return a DataFrame reverse sorted alphabetically based on column division?
Answer options
- A. storesDF.orderBy("division", ascending – False)
- B. storesDF.orderBy(["division"], ascending = [0])
- C. storesDF.orderBy(col("division").asc())
- D. storesDF.sort("division", ascending – False)
- E. storesDF.sort(desc("division"))
Correct answer: C
Explanation
The correct answer is C because it sorts the division column in ascending order instead of the required descending order. Options A, B, D, and E correctly implement descending sorting for the division column, either through the use of ascending = False or the desc function.