@@ -79,16 +79,16 @@ struct PartitionNthToIndices {
7979 }
8080 const auto p = PartitionNullsAndNans<ArrayType, NonStablePartitioner>(
8181 out_span, arr, 0 , options.null_placement );
82- auto nth_begin = out_span.begin () + pivot;
83- if (nth_begin > = p.non_null_like_range .begin () &&
84- nth_begin < p.non_null_like_range .end ()) {
85- std::ranges::nth_element (
86- p. non_null_like_range . begin () , nth_begin, p. non_null_like_range . end () ,
87- [&arr](uint64_t left, uint64_t right) {
88- const auto lval = GetView::LogicalValue (arr.GetView (left));
89- const auto rval = GetView::LogicalValue (arr.GetView (right));
90- return lval < rval;
91- });
82+ auto nth_begin = out_span.data () + pivot;
83+ auto non_null_begin = p.non_null_like_range .data ();
84+ auto non_null_end = p. non_null_like_range . data () + p.non_null_like_range .size ();
85+ if (nth_begin >= non_null_begin && nth_begin < non_null_end) {
86+ std::nth_element (non_null_begin , nth_begin, non_null_end ,
87+ [&arr](uint64_t left, uint64_t right) {
88+ const auto lval = GetView::LogicalValue (arr.GetView (left));
89+ const auto rval = GetView::LogicalValue (arr.GetView (right));
90+ return lval < rval;
91+ });
9292 }
9393 return Status::OK ();
9494 }
@@ -156,16 +156,14 @@ class ArrayCompareSorter {
156156 indices, values, offset, options.null_placement );
157157 if (options.order == SortOrder::Ascending) {
158158 std::ranges::stable_sort (
159- p.non_null_like_range ,
160- [&values, &offset](uint64_t left, uint64_t right) {
159+ p.non_null_like_range , [&values, &offset](uint64_t left, uint64_t right) {
161160 const auto lhs = GetView::LogicalValue (values.GetView (left - offset));
162161 const auto rhs = GetView::LogicalValue (values.GetView (right - offset));
163162 return lhs < rhs;
164163 });
165164 } else {
166165 std::ranges::stable_sort (
167- p.non_null_like_range ,
168- [&values, &offset](uint64_t left, uint64_t right) {
166+ p.non_null_like_range , [&values, &offset](uint64_t left, uint64_t right) {
169167 const auto lhs = GetView::LogicalValue (values.GetView (left - offset));
170168 const auto rhs = GetView::LogicalValue (values.GetView (right - offset));
171169 // We don't use 'left > right' here to reduce required operator.
0 commit comments