pyspark.sql.Column.asc

Column.asc() → pyspark.sql.column.Column

Returns a sort expression based on the ascending order of the column.

Changed in version 3.4.0: Supports Spark Connect.

Examples

>>> from pyspark.sql import Row
>>> df = spark.createDataFrame([('Tom', 80), ('Alice', None)], ["name", "height"])
>>> df.select(df.name).orderBy(df.name.asc()).collect()
[Row(name='Alice'), Row(name='Tom')]