xinrong-databricks commented on a change in pull request #35840:
URL: https://github.com/apache/spark/pull/35840#discussion_r836593993



##########
File path: python/pyspark/pandas/frame.py
##########
@@ -6846,7 +6866,16 @@ def _sort(
             (False, "last"): Column.desc_nulls_last,
         }
         by = [mapper[(asc, na_position)](scol) for scol, asc in zip(by, 
ascending)]
-        sdf = self._internal.resolved_copy.spark_frame.sort(*by, 
NATURAL_ORDER_COLUMN_NAME)
+
+        natural_order_scol = F.col(NATURAL_ORDER_COLUMN_NAME)
+
+        if keep == "last":
+            natural_order_scol = Column.desc(natural_order_scol)
+        elif keep != "first":

Review comment:
       Good idea, modified.

##########
File path: python/pyspark/pandas/frame.py
##########
@@ -7321,6 +7338,10 @@ def nlargest(self, n: int, columns: Union[Name, 
List[Name]]) -> "DataFrame":
             Number of rows to return.
         columns : label or list of labels
             Column label(s) to order by.
+        keep : {'first', 'last'}, default 'first'

Review comment:
       Sure.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to