
Explanation:
To sort a DataFrame alphabetically based on a column in ascending order, the correct method is to use sort or orderBy without specifying a descending order. Option A correctly uses sort("division"), which sorts the DataFrame in ascending order by default. Options B, C, and E incorrectly sort the DataFrame in descending order due to the use of desc. Option D contains a syntax error with ascending - true instead of the correct ascending=True. Therefore, the only correct option is A.
Ultimate access to all questions.
No comments yet.
Which of the following code blocks returns a DataFrame sorted in alphabetical order by the column division?
A
storesDF.sort("division")
B
storesDF.orderBy(desc("division"))
C
storesDF.orderBy(col("division").desc())
D
storesDF.orderBy("division", ascending - true)
E
storesDF.sort(desc("division"))