>>> df.show()
+---+----+------------+
| id|num1|     numbers|
+---+----+------------+
|  1| 100|[12, 23, 45]|
|  2| 200|        [67]|
|  3| 300|        [12]|
|  4| 400|    [98, 54]|
+---+----+------------+

PySpark code

>>> df.select(F.array_compact(F.array_sort(F.col("numbers"))).alias("compact_sorted_numbers")).show()
+----------------------+
|compact_sorted_numbers|
+----------------------+
|[12, 23, 45]          |
|[67]                  |
|[12]                  |
|[54, 98]              |
+----------------------+

teradatamlspk code

# Sort the numbers array
>>> temp_df = df.withColumn("sorted_numbers", F.array_sort(F.col("numbers")))

# Compact the sorted array
>>> temp_df.select(F.array_compact(F.col("sorted_numbers")).alias("compact_sorted_numbers")).show()
+----------------------+
|compact_sorted_numbers|
+----------------------+
|               (54,98)|
|                  (67)|
|            (12,23,45)|
|                  (12)|
+----------------------+