pyspark.sql.functions.array_sort

pyspark.sql.functions.array_sort(col)[source]

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.

New in version 2.4.0.

Parameters
colColumn or str

name of column or expression

Examples

>>> 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=[])]