May 13, 2023

Pyspark sort_array()

 

sort_array (for lists)

  • It can be confusing to differentiate between the different sorting functions in PySpark. In this case, a particularity about sort_array has to be considered: 

  • The sort direction is given by the second argument, not by the desc method. Luckily, this is documented in the documentation (link below). 

  • Also, for solving this question you need to understand the difference between sort and sort_array. With sort, you cannot sort values in arrays. 

  • Also, sort is a method of DataFrame, while sort_array is a method of pyspark.sql.functions.


No comments:

Post a Comment