xinrong-databricks opened a new pull request, #36076: URL: https://github.com/apache/spark/pull/36076
### What changes were proposed in this pull request? Support `return_indexer` parameter of `Index/MultiIndex.sort_values`. Note that this method returns indexer as a pandas-on-Spark index while pandas returns it as a list. That's because indexer in pandas-on-Spark may not fit in memory. ### Why are the changes needed? To reach parity with pandas. ### Does this PR introduce _any_ user-facing change? Yes. `return_indexer` parameter of `Index/MultiIndex.sort_values` is supported as below. Index ```py >>> idx = ps.Index([10, 100, 1, 1000]) >>> idx Int64Index([10, 100, 1, 1000], dtype='int64') >>> idx.sort_values(ascending=False, return_indexer=True) (Int64Index([1000, 100, 10, 1], dtype='int64'), Int64Index([3, 1, 0, 2], dtype='int64')) ``` MultiIndex ```py >>> psidx = ps.MultiIndex.from_tuples([('a', 'x', 1), ('c', 'y', 2), ('b', 'z', 3)]) >>> psidx MultiIndex([('a', 'x', 1), ('c', 'y', 2), ('b', 'z', 3)], ) >>> psidx.sort_values(ascending=False, return_indexer=True) (MultiIndex([('c', 'y', 2), ('b', 'z', 3), ('a', 'x', 1)], ), Int64Index([1, 2, 0], dtype='int64')) ``` ### How was this patch tested? Unit test. -- 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: reviews-unsubscr...@spark.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org