jorisvandenbossche commented on code in PR #14781:
URL: https://github.com/apache/arrow/pull/14781#discussion_r1037885164
##########
python/pyarrow/tests/test_array.py:
##########
@@ -3287,3 +3287,34 @@ def test_to_pandas_timezone():
arr = pa.chunked_array([arr])
s = arr.to_pandas()
assert s.dt.tz is not None
+
+
+def test_array_sort():
+ arr = pa.array([5, 7, 35], type=pa.int64())
+ sorted_arr = arr.sort("descending")
+ assert sorted_arr.to_pylist() == [35, 7, 5]
+
+ arr = pa.chunked_array([[1, 2, 3], [4, 5, 6]])
+ sorted_arr = arr.sort("descending")
+ assert sorted_arr.to_pylist() == [6, 5, 4, 3, 2, 1]
+
+ arr = pa.array([5, 7, 35, None], type=pa.int64())
+ sorted_arr = arr.sort("descending", null_placement="at_end")
+ assert sorted_arr.to_pylist() == [35, 7, 5, None]
+ sorted_arr = arr.sort("descending", null_placement="at_start")
+ assert sorted_arr.to_pylist() == [None, 35, 7, 5]
+
+
+def test_struct_array_sort():
+ arr = pa.StructArray.from_arrays([
+ pa.array([5, 7, 7, 35], type=pa.int64()),
+ pa.array(["foo", "car", "bar", "foobar"])
+ ], names=["a", "b"])
+
+ sorted_arr = arr.sort("descending", fieldname="a")
Review Comment:
Also add `arr.sort()` case without fieldname specified?
--
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]