jorisvandenbossche commented on a change in pull request #8805:
URL: https://github.com/apache/arrow/pull/8805#discussion_r544417190
##########
File path: python/pyarrow/tests/test_compute.py
##########
@@ -1017,3 +1017,51 @@ def test_partition_nth():
for i in range(pivot))
assert all(data[indices[i]] >= data[indices[pivot]]
for i in range(pivot, len(data)))
+
+
+def test_array_sort_indices():
+ arr = pa.array([1, 2, None, 0])
+ result = pc.array_sort_indices(arr)
+ assert result.to_pylist() == [3, 0, 1, 2]
+ result = pc.array_sort_indices(arr, order="ascending")
+ assert result.to_pylist() == [3, 0, 1, 2]
+ result = pc.array_sort_indices(arr, order="descending")
+ assert result.to_pylist() == [1, 0, 3, 2]
+
+ with pytest.raises(ValueError, match="not a valid order"):
+ pc.array_sort_indices(arr, order="nonscending")
+
+
+def test_sort_indices_array():
+ arr = pa.array([1, 2, None, 0])
+ result = pc.sort_indices(arr)
+ assert result.to_pylist() == [3, 0, 1, 2]
+ result = pc.sort_indices(arr, sort_keys=[("dummy", "ascending")])
Review comment:
> Having to repeat "ascending" or "descending" is much too cumbersome.
Also if you have different order for different columns? (assuming that the
all-ascending or all-descending cases would be covered by a shortcut like an
`order` keyword mentioned above)
(I would personally be fine with leaving that case as cumbersome to write, I
think)
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]