Github user ueshin commented on a diff in the pull request:
https://github.com/apache/spark/pull/21021#discussion_r182999463
--- Diff: python/pyspark/sql/functions.py ---
@@ -2168,6 +2171,23 @@ def sort_array(col, asc=True):
return Column(sc._jvm.functions.sort_array(_to_java_column(col), asc))
+@since(2.4)
+def array_sort(col):
+ """
+ Collection function: sorts the input array in ascending order. The
elements of the input array
+ must be orderable. Null elements will be placed at the end of the
returned array.
+
+ :param col: name of column or expression
+
+ >>> from pyspark.sql.functions import array_sort
+ >>> df = spark.createDataFrame([([2, 1, None, 3],),([1],),([],)],
['data'])
+ >>> df.select(array_sort(df.data).alias('r')).collect()
+ [Row(r=[1, 2, 3, None]), Row(r=[1]), Row(r=[])]
+ """
--- End diff --
nit: an extra space?
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]