sundy-li commented on a change in pull request #9602:
URL: https://github.com/apache/arrow/pull/9602#discussion_r588974704



##########
File path: rust/arrow/src/compute/kernels/sort.rs
##########
@@ -37,10 +37,33 @@ use TimeUnit::*;
 /// Returns an `ArrowError::ComputeError(String)` if the array type is either 
unsupported by `sort_to_indices` or `take`.
 ///
 pub fn sort(values: &ArrayRef, options: Option<SortOptions>) -> 
Result<ArrayRef> {
-    let indices = sort_to_indices(values, options)?;
+    let indices = sort_to_indices(values, options, None)?;
     take(values.as_ref(), &indices, None)
 }
 
+/// Sort the `ArrayRef` partially.
+/// Return an sorted `ArrayRef`, discarding the data after limit.
+pub fn partial_sort(
+    values: &ArrayRef,
+    options: Option<SortOptions>,
+    limit: Option<usize>,
+) -> Result<ArrayRef> {
+    let indices = sort_to_indices(values, options, limit)?;
+    take(values.as_ref(), &indices, None)
+}
+
+#[inline]
+fn sort_by<T, F>(array: &mut [T], limit: usize, cmp: F)
+where
+    F: FnMut(&T, &T) -> Ordering,

Review comment:
       Just to be compatible with `std::sort_by`.




----------------------------------------------------------------
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]


Reply via email to